Tabnine Logo
RexTableInputRef
Code IndexAdd Tabnine to your IDE (free)

How to use
RexTableInputRef
in
org.apache.calcite.rex

Best Java code snippets using org.apache.calcite.rex.RexTableInputRef (Showing top 20 results out of 315)

origin: apache/hive

 return null;
List<Integer> cols = tabToOriginColumns.get(inputRef.getTableRef());
if (cols == null) {
 cols = new ArrayList<>();
cols.add(inputRef.getIndex());
tabToOriginColumns.put(inputRef.getTableRef(), cols);
origin: apache/hive

  tRef.getTable().getRowType().getFieldList().get(foreignKeyPos).getType();
RexTableInputRef foreignKeyColumnRef =
  RexTableInputRef.of(tRef, foreignKeyPos, foreignKeyColumnType);
int uniqueKeyPos = constraint.getColumnPairs().get(pos).target;
RexTableInputRef uniqueKeyColumnRef = RexTableInputRef.of(nonFkTable, uniqueKeyPos,
  nonFkTable.getTable().getRowType().getFieldList().get(uniqueKeyPos).getType());
if (ecT.getEquivalenceClassesMap().containsKey(uniqueKeyColumnRef) &&
origin: Qihoo360/Quicksql

 @Override public RexNode visitTableInputRef(RexTableInputRef inputRef) {
  if (ec != null) {
   Set<RexTableInputRef> s = ec.get(inputRef);
   if (s != null) {
    inputRef = s.iterator().next();
   }
  }
  if (tableMapping != null) {
   inputRef = RexTableInputRef.of(
     tableMapping.get(inputRef.getTableRef()),
     inputRef.getIndex(),
     inputRef.getType());
  }
  return inputRef;
 }
};
origin: Qihoo360/Quicksql

@Test public void testExpressionLineageTwoColumns() {
 // mgr is column 3 in catalog.sales.emp
 // deptno is column 7 in catalog.sales.emp
 final RelNode rel = convertSql("select mgr, deptno from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref1 = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r1 = mq.getExpressionLineage(rel, ref1);
 assertThat(r1.size(), is(1));
 final RexTableInputRef result1 = (RexTableInputRef) r1.iterator().next();
 assertTrue(result1.getQualifiedName().equals(EMP_QNAME));
 assertThat(result1.getIndex(), is(3));
 final RexNode ref2 = RexInputRef.of(1, rel.getRowType().getFieldList());
 final Set<RexNode> r2 = mq.getExpressionLineage(rel, ref2);
 assertThat(r2.size(), is(1));
 final RexTableInputRef result2 = (RexTableInputRef) r2.iterator().next();
 assertTrue(result2.getQualifiedName().equals(EMP_QNAME));
 assertThat(result2.getIndex(), is(7));
 assertThat(result1.getIdentifier(), is(result2.getIdentifier()));
}
origin: Qihoo360/Quicksql

@Test public void testExpressionLineageInnerJoinRight() {
 // ename is column 0 in catalog.sales.bonus
 final RelNode rel = convertSql("select bonus.ename from emp join bonus using (ename)");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertThat(r.size(), is(1));
 final RexTableInputRef result = (RexTableInputRef) r.iterator().next();
 assertTrue(result.getQualifiedName().equals(ImmutableList.of("CATALOG", "SALES", "BONUS")));
 assertThat(result.getIndex(), is(0));
}
origin: Qihoo360/Quicksql

 @Override public Void visitTableInputRef(RexTableInputRef ref) {
  occurrences.add(ref.getTableRef());
  return super.visitTableInputRef(ref);
 }
};
origin: Qihoo360/Quicksql

public static RexTableInputRef of(RelTableRef tableRef, int index, RelDataType type) {
 return new RexTableInputRef(tableRef, index, type);
}
origin: org.apache.calcite/calcite-core

@Test public void testExpressionLineageUnion() {
 // sal is column 5 in catalog.sales.emp
 final RelNode rel = convertSql("select sal from (\n"
   + "  select * from emp union all select * from emp) "
   + "where deptno = 10");
 final RelNode tableRel = convertSql("select * from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 final String inputRef = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
 assertThat(r.size(), is(2));
 for (RexNode result : r) {
  final String resultString = result.toString();
  assertThat(resultString, startsWith(EMP_QNAME.toString()));
  assertThat(resultString, endsWith(inputRef));
 }
 Iterator<RexNode> it = r.iterator();
 assertThat(((RexTableInputRef) it.next()).getIdentifier(),
   not(((RexTableInputRef) it.next()).getIdentifier()));
}
origin: Qihoo360/Quicksql

@Override public RexNode visitTableInputRef(RexTableInputRef ref) {
 Collection<Integer> c = exprsLineage.get(ref.toString());
 if (c.isEmpty()) {
  // Cannot map expression
  throw Util.FoundOne.NULL;
 }
 int pos = c.iterator().next();
 if (rewritingMapping != null) {
  pos = rewritingMapping.getTargetOpt(pos);
  if (pos == -1) {
   // Cannot map expression
   throw Util.FoundOne.NULL;
  }
 }
 if (node != null) {
  return rexBuilder.makeInputRef(node, pos);
 }
 return rexBuilder.makeInputRef(ref.getType(), pos);
}
origin: org.apache.calcite/calcite-core

@Override public RexNode visitTableInputRef(RexTableInputRef ref) {
 Collection<Integer> c = exprsLineage.get(ref);
 if (c.isEmpty()) {
  // Cannot map expression
  throw Util.FoundOne.NULL;
 }
 int pos = c.iterator().next();
 if (rewritingMapping != null) {
  pos = rewritingMapping.getTargetOpt(pos);
  if (pos == -1) {
   // Cannot map expression
   throw Util.FoundOne.NULL;
  }
 }
 if (node != null) {
  return rexBuilder.makeInputRef(node, pos);
 }
 return rexBuilder.makeInputRef(ref.getType(), pos);
}
origin: Qihoo360/Quicksql

 @Override public RexNode visitTableInputRef(RexTableInputRef inputRef) {
  if (tableMapping != null) {
   inputRef = RexTableInputRef.of(
     tableMapping.get(inputRef.getTableRef()),
     inputRef.getIndex(),
     inputRef.getType());
  }
  if (ec != null) {
   Set<RexTableInputRef> s = ec.get(inputRef);
   if (s != null) {
    inputRef = s.iterator().next();
   }
  }
  return inputRef;
 }
};
origin: Qihoo360/Quicksql

@Test public void testExpressionLineageTwoColumnsSwapped() {
 // deptno is column 7 in catalog.sales.emp
 // mgr is column 3 in catalog.sales.emp
 final RelNode rel = convertSql("select deptno, mgr from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref1 = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r1 = mq.getExpressionLineage(rel, ref1);
 assertThat(r1.size(), is(1));
 final RexTableInputRef result1 = (RexTableInputRef) r1.iterator().next();
 assertTrue(result1.getQualifiedName().equals(EMP_QNAME));
 assertThat(result1.getIndex(), is(7));
 final RexNode ref2 = RexInputRef.of(1, rel.getRowType().getFieldList());
 final Set<RexNode> r2 = mq.getExpressionLineage(rel, ref2);
 assertThat(r2.size(), is(1));
 final RexTableInputRef result2 = (RexTableInputRef) r2.iterator().next();
 assertTrue(result2.getQualifiedName().equals(EMP_QNAME));
 assertThat(result2.getIndex(), is(3));
 assertThat(result1.getIdentifier(), is(result2.getIdentifier()));
}
origin: Qihoo360/Quicksql

@Test public void testExpressionLineageInnerJoinLeft() {
 // ename is column 1 in catalog.sales.emp
 final RelNode rel = convertSql("select ename from emp,dept");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertThat(r.size(), is(1));
 final RexTableInputRef result = (RexTableInputRef) r.iterator().next();
 assertTrue(result.getQualifiedName().equals(EMP_QNAME));
 assertThat(result.getIndex(), is(1));
}
origin: org.apache.calcite/calcite-core

 @Override public Void visitTableInputRef(RexTableInputRef ref) {
  occurrences.add(ref.getTableRef());
  return super.visitTableInputRef(ref);
 }
};
origin: org.apache.calcite/calcite-core

public static RexTableInputRef of(RelTableRef tableRef, int index, RelDataType type) {
 return new RexTableInputRef(tableRef, index, type);
}
origin: Qihoo360/Quicksql

@Test public void testExpressionLineageUnion() {
 // sal is column 5 in catalog.sales.emp
 final RelNode rel = convertSql("select sal from (\n"
   + "  select * from emp union all select * from emp) "
   + "where deptno = 10");
 final RelNode tableRel = convertSql("select * from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 final String inputRef = RexInputRef.of(5, tableRel.getRowType().getFieldList()).toString();
 assertThat(r.size(), is(2));
 for (RexNode result : r) {
  final String resultString = result.toString();
  assertThat(resultString, startsWith(EMP_QNAME.toString()));
  assertThat(resultString, endsWith(inputRef));
 }
 Iterator<RexNode> it = r.iterator();
 assertThat(((RexTableInputRef) it.next()).getIdentifier(),
   not(((RexTableInputRef) it.next()).getIdentifier()));
}
origin: org.apache.calcite/calcite-core

 @Override public RexNode visitTableInputRef(RexTableInputRef inputRef) {
  if (tableMapping != null) {
   inputRef = RexTableInputRef.of(
     tableMapping.get(inputRef.getTableRef()),
     inputRef.getIndex(),
     inputRef.getType());
  }
  if (ec != null) {
   Set<RexTableInputRef> s = ec.get(inputRef);
   if (s != null) {
    inputRef = s.iterator().next();
   }
  }
  return inputRef;
 }
};
origin: org.apache.calcite/calcite-core

@Test public void testExpressionLineageTwoColumnsSwapped() {
 // deptno is column 7 in catalog.sales.emp
 // mgr is column 3 in catalog.sales.emp
 final RelNode rel = convertSql("select deptno, mgr from emp");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref1 = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r1 = mq.getExpressionLineage(rel, ref1);
 assertThat(r1.size(), is(1));
 final RexTableInputRef result1 = (RexTableInputRef) r1.iterator().next();
 assertEquals(result1.getQualifiedName(), EMP_QNAME);
 assertThat(result1.getIndex(), is(7));
 final RexNode ref2 = RexInputRef.of(1, rel.getRowType().getFieldList());
 final Set<RexNode> r2 = mq.getExpressionLineage(rel, ref2);
 assertThat(r2.size(), is(1));
 final RexTableInputRef result2 = (RexTableInputRef) r2.iterator().next();
 assertEquals(result2.getQualifiedName(), EMP_QNAME);
 assertThat(result2.getIndex(), is(3));
 assertThat(result1.getIdentifier(), is(result2.getIdentifier()));
}
origin: org.apache.calcite/calcite-core

@Test public void testExpressionLineageInnerJoinRight() {
 // ename is column 0 in catalog.sales.bonus
 final RelNode rel = convertSql("select bonus.ename from emp join bonus using (ename)");
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
 final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
 assertThat(r.size(), is(1));
 final RexTableInputRef result = (RexTableInputRef) r.iterator().next();
 assertEquals(result.getQualifiedName(), ImmutableList.of("CATALOG", "SALES", "BONUS"));
 assertThat(result.getIndex(), is(0));
}
origin: apache/hive

  tRef.getTable().getRowType().getFieldList().get(foreignKeyPos).getType();
RexTableInputRef foreignKeyColumnRef =
  RexTableInputRef.of(tRef, foreignKeyPos, foreignKeyColumnType);
int uniqueKeyPos = constraint.getColumnPairs().get(pos).target;
RexTableInputRef uniqueKeyColumnRef = RexTableInputRef.of(nonFkTable, uniqueKeyPos,
  nonFkTable.getTable().getRowType().getFieldList().get(uniqueKeyPos).getType());
if (ecT.getEquivalenceClassesMap().containsKey(uniqueKeyColumnRef) &&
org.apache.calcite.rexRexTableInputRef

Javadoc

Variable which references a column of a table occurrence in a relational plan.

This object is used by org.apache.calcite.rel.metadata.BuiltInMetadata.ExpressionLineageand org.apache.calcite.rel.metadata.BuiltInMetadata.AllPredicates.

Given a relational expression, its purpose is to be able to reference uniquely the provenance of a given expression. For that, it uses a unique table reference (contained in a RelTableRef) and an column index within the table.

For example, A.#0.$3 + 2 column $3 in the 0occurrence of table A in the plan.

Note that this kind of RexNode is an auxiliary data structure with a very specific purpose and should not be used in relational expressions.

Most used methods

  • getIndex
  • getTableRef
  • of
  • <init>
  • getIdentifier
  • getQualifiedName
  • getType
  • toString

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • getApplicationContext (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Notification (javax.management)
  • JButton (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now