static PlanNode createDependentSetNode(
      String id, List<DependentSetCriteria.AttributeComparison> expressions) {
    DependentSetCriteria crit = createDependentSetCriteria(id, expressions);

    PlanNode selectNode = RelationalPlanner.createSelectNode(crit, false);

    selectNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
    return selectNode;
  }
Exemple #2
0
  public Object lookupCodeValue(
      CommandContext context,
      String codeTableName,
      String returnElementName,
      String keyElementName,
      Object keyValue)
      throws BlockedException, TeiidComponentException, TeiidProcessingException {
    // we are not using a resolved form of a lookup, so we canonicallize with upper case
    codeTableName = codeTableName.toUpperCase();
    keyElementName = keyElementName.toUpperCase();
    returnElementName = returnElementName.toUpperCase();
    String matTableName =
        CODE_PREFIX
            + codeTableName
            + ElementSymbol.SEPARATOR
            + keyElementName
            + ElementSymbol.SEPARATOR
            + returnElementName;

    TupleSource ts = context.getCodeLookup(matTableName, keyValue);
    if (ts == null) {
      QueryMetadataInterface metadata = context.getMetadata();

      TempMetadataID id =
          context
              .getGlobalTableStore()
              .getCodeTableMetadataId(
                  codeTableName, returnElementName, keyElementName, matTableName);

      ElementSymbol keyElement = new ElementSymbol(keyElementName, new GroupSymbol(matTableName));
      ElementSymbol returnElement =
          new ElementSymbol(returnElementName, new GroupSymbol(matTableName));
      keyElement.setType(
          DataTypeManager.getDataTypeClass(
              metadata.getElementType(
                  metadata.getElementID(
                      codeTableName + ElementSymbol.SEPARATOR + keyElementName))));
      returnElement.setType(
          DataTypeManager.getDataTypeClass(
              metadata.getElementType(
                  metadata.getElementID(
                      codeTableName + ElementSymbol.SEPARATOR + returnElementName))));

      Query query =
          RelationalPlanner.createMatViewQuery(
              id, matTableName, Arrays.asList(returnElement), true);
      query.setCriteria(
          new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue)));

      ts = registerQuery(context, context.getTempTableStore(), query);
    }
    try {
      List<?> row = ts.nextTuple();
      Object result = null;
      if (row != null) {
        result = row.get(0);
      }
      ts.closeSource();
      return result;
    } catch (BlockedException e) {
      context.putCodeLookup(matTableName, keyValue, ts);
      throw e;
    }
  }