示例#1
0
 public static void convertVarNodesToDefineFunctions(VarTable varTable, List<INode> iNodes) {
   // Send back the change to the tPigLoad node if you modified the configure of define dunctions
   for (INode iNode : iNodes) {
     IElementParameter elementParameter =
         iNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION);
     if (elementParameter != null && elementParameter.getValue() instanceof List) {
       List<Map<String, String>> defineFunctions =
           (List<Map<String, String>>) elementParameter.getValue();
       defineFunctions.clear();
       defineFunctionsAlias.clear();
       for (VarNode varNode : varTable.getNodes()) {
         if (iNode.getUniqueName().equals(varNode.getType())) {
           Map<String, String> item = new HashMap<String, String>();
           item.put(
               PigMapConstants.FUNCTION_ALIAS,
               TalendQuoteUtils.addQuotesIfNotExist(varNode.getName()));
           if (varNode.getExpression() != null) {
             String newString = varNode.getExpression().trim();
             if (newString.length() > 0) {
               newString = TalendQuoteUtils.addQuotesIfNotExist(newString);
             }
             item.put(PigMapConstants.UDF_FUNCTION, newString);
           } else {
             item.put(PigMapConstants.UDF_FUNCTION, ""); // $NON-NLS-1$
           }
           defineFunctions.add(item);
           String key = varNode.getName();
           if (!defineFunctionsAlias.containsKey(key)) {
             defineFunctionsAlias.put(key, varNode.getExpression());
           }
         }
       }
     }
   }
 }
示例#2
0
 public static void convertVarNodesToDefineFunctions(VarTable varTable) {
   // if you modified the configure of var define functions , we need update .
   defineFunctionsAlias.clear();
   for (VarNode varNode : varTable.getNodes()) {
     Map<String, String> item = new HashMap<String, String>();
     item.put(
         PigMapConstants.FUNCTION_ALIAS, TalendQuoteUtils.addQuotesIfNotExist(varNode.getName()));
     item.put(
         PigMapConstants.UDF_FUNCTION,
         TalendQuoteUtils.addQuotesIfNotExist(varNode.getExpression()));
     String key = varNode.getName();
     if (!defineFunctionsAlias.containsKey(key)) {
       defineFunctionsAlias.put(key, varNode.getExpression());
     }
   }
 }