private List<RexNode> extractFilterPreds(Filter filterOp) { List<RexNode> conjs = new ArrayList<>(); for (RexNode r : HiveRelOptUtil.conjunctions(filterOp.getCondition())) { if (r.getKind() == SqlKind.IS_NOT_NULL) { RexCall isNotNullNode = (RexCall) r; if (RexUtil.isReferenceOrAccess(isNotNullNode.getOperands().get(0), true)) { ImmutableBitSet ref = RelOptUtil.InputFinder.bits(isNotNullNode); RelColumnOrigin co = mq.getColumnOrigin(filterOp, ref.nextSetBit(0)); if (co == null) { // We add it back conjs.add(r); continue; } RelOptHiveTable table = (RelOptHiveTable) co.getOriginTable(); List<ColStatistics> colStats = table.getColStat(ImmutableList.of(co.getOriginColumnOrdinal()), true); if (colStats == null || colStats.isEmpty() || colStats.get(0).getNumNulls() != 0) { // We add it back conjs.add(r); } } } else { conjs.add(r); } } return conjs; }
private ColStatistics extractColStats(RexInputRef ref) { RelColumnOrigin columnOrigin = this.metadataProvider.getColumnOrigin(filterOp, ref.getIndex()); if (columnOrigin != null) { RelOptHiveTable table = (RelOptHiveTable) columnOrigin.getOriginTable(); if (table != null) { ColStatistics colStats = table.getColStat(Lists.newArrayList(columnOrigin.getOriginColumnOrdinal()), false).get(0); if (colStats != null && StatsUtils.areColumnStatsUptoDateForQueryAnswering( table.getHiveTableMD(), table.getHiveTableMD().getParameters(), colStats.getColumnName())) { return colStats; } } } return null; }
if (null != colOrigs) { for (RelColumnOrigin colOrig : colOrigs) { RelOptHiveTable hiveTbl = (RelOptHiveTable)colOrig.getOriginTable(); if(hiveTbl.getPartColInfoMap().containsKey(colOrig.getOriginColumnOrdinal())) {
if (null != colOrigs) { for (RelColumnOrigin colOrig : colOrigs) { RelOptHiveTable hiveTbl = (RelOptHiveTable)colOrig.getOriginTable(); if(hiveTbl.getPartColInfoMap().containsKey(colOrig.getOriginColumnOrdinal())) {
private Long extractRowCount(RexInputRef ref) { RelColumnOrigin columnOrigin = this.metadataProvider.getColumnOrigin(filterOp, ref.getIndex()); if (columnOrigin != null) { RelOptHiveTable table = (RelOptHiveTable) columnOrigin.getOriginTable(); if (table != null) { if (StatsUtils.areBasicStatsUptoDateForQueryAnswering(table.getHiveTableMD(), table.getHiveTableMD().getParameters())) { return StatsUtils.getNumRows(table.getHiveTableMD()); } } } return null; }
private Pair<Number,Number> extractMaxMin(RexInputRef ref) { Number max = null; Number min = null; RelColumnOrigin columnOrigin = this.metadataProvider.getColumnOrigin(filterOp, ref.getIndex()); if (columnOrigin != null) { RelOptHiveTable table = (RelOptHiveTable) columnOrigin.getOriginTable(); if (table != null) { ColStatistics colStats = table.getColStat(Lists.newArrayList(columnOrigin.getOriginColumnOrdinal())).get(0); if (colStats != null && StatsSetupConst.areColumnStatsUptoDate( table.getHiveTableMD().getParameters(), colStats.getColumnName())) { Range range = colStats.getRange(); if (range != null) { max = range.maxValue; min = range.minValue; } } } } return Pair.<Number,Number>of(max, min); }
/** * @param origin * @return the table */ public static List<String> getTable(RelColumnOrigin origin) { return origin.getOriginTable().getQualifiedName(); }
/** * Determines the origin of a {@link RelNode}, provided it maps to a single * table, optionally with filtering and projection. * * @param rel the RelNode * * @return the table, if the RelNode is a simple table; otherwise null */ public RelOptTable getTableOrigin(RelNode rel) { // Determine the simple origin of the first column in the // RelNode. If it's simple, then that means that the underlying // table is also simple, even if the column itself is derived. final Set<RelColumnOrigin> colOrigins = getColumnOrigins(rel, 0); if (colOrigins == null || colOrigins.size() == 0) { return null; } return colOrigins.iterator().next().getOriginTable(); }
private Set<RelColumnOrigin> createDerivedColumnOrigins( Set<RelColumnOrigin> inputSet) { if (inputSet == null) { return null; } final Set<RelColumnOrigin> set = new HashSet<>(); for (RelColumnOrigin rco : inputSet) { RelColumnOrigin derived = new RelColumnOrigin( rco.getOriginTable(), rco.getOriginColumnOrdinal(), true); set.add(derived); } return set; } }
private Set<RelColumnOrigin> createDerivedColumnOrigins( Set<RelColumnOrigin> inputSet) { if (inputSet == null) { return null; } final Set<RelColumnOrigin> set = new HashSet<>(); for (RelColumnOrigin rco : inputSet) { RelColumnOrigin derived = new RelColumnOrigin( rco.getOriginTable(), rco.getOriginColumnOrdinal(), true); set.add(derived); } return set; } }
private Set<RelColumnOrigin> createDerivedColumnOrigins( Set<RelColumnOrigin> inputSet) { if (inputSet == null) { return null; } final Set<RelColumnOrigin> set = new HashSet<>(); for (RelColumnOrigin rco : inputSet) { RelColumnOrigin derived = new RelColumnOrigin( rco.getOriginTable(), rco.getOriginColumnOrdinal(), true); set.add(derived); } return set; } }
/** * @param origin * @return the column name */ public static String getColName(RelColumnOrigin origin) { return origin.getOriginTable().getRowType().getFieldNames().get(origin.getOriginColumnOrdinal()); } }
/** * Determines the origin of a {@link RelNode}, provided it maps to a single * table, optionally with filtering and projection. * * @param rel the RelNode * * @return the table, if the RelNode is a simple table; otherwise null */ public RelOptTable getTableOrigin(RelNode rel) { // Determine the simple origin of the first column in the // RelNode. If it's simple, then that means that the underlying // table is also simple, even if the column itself is derived. if (rel.getRowType().getFieldCount() == 0) { return null; } final Set<RelColumnOrigin> colOrigins = getColumnOrigins(rel, 0); if (colOrigins == null || colOrigins.size() == 0) { return null; } return colOrigins.iterator().next().getOriginTable(); }
if (null != colOrigs) { for (RelColumnOrigin colOrig : colOrigs) { RelOptHiveTable hiveTbl = (RelOptHiveTable)colOrig.getOriginTable(); if(hiveTbl.getPartColInfoMap().containsKey(colOrig.getOriginColumnOrdinal())) {
@Override public JoinCondition apply(Pair<Integer, Integer> pair) { final RelColumnOrigin leftColumnOrigin = Iterables.getOnlyElement(relMetadataQuery.getColumnOrigins(joinPrel.getLeft(), pair.left)); final RelColumnOrigin rightColumnOrigin = Iterables.getOnlyElement(relMetadataQuery.getColumnOrigins(joinPrel.getRight(), pair.right)); final RelOptTable leftTable = leftColumnOrigin.getOriginTable(); final RelOptTable rightTable = rightColumnOrigin.getOriginTable(); int leftOrdinal = leftColumnOrigin.getOriginColumnOrdinal(); int rightOrdinal = rightColumnOrigin.getOriginColumnOrdinal(); return new JoinCondition() .setBuildSideColumn(rightTable.getRowType().getFieldList().get(rightOrdinal).getName()) .setProbeSideColumn(leftTable.getRowType().getFieldList().get(leftOrdinal).getName()) .setBuildSideTableId(tables.get(rightTable.getQualifiedName())) .setProbeSideTableId(tables.get(leftTable.getQualifiedName())); } })
} else { for (RelColumnOrigin column : origins) { if (column.getOriginTable() == null) { supportContains = false; } else { NamespaceTable namespaceTable2 = column.getOriginTable().unwrap(NamespaceTable.class); if (namespaceTable2 != null) { if(!namespaceTable2.getStoragePluginId().getCapabilities().getCapability(SourceCapabilities.SUPPORTS_CONTAINS)){
result.size()); for (RelColumnOrigin rco : result) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); String actualUnqualifiedName = Iterables.getLast(actualTableName);
result.size()); for (RelColumnOrigin rco : result) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); String actualUnqualifiedName = Iterables.getLast(actualTableName);
public static void checkColumnOrigin( RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); assertEquals( Iterables.getLast(actualTableName), expectedTableName); assertEquals( actualTable.getRowType() .getFieldList() .get(rco.getOriginColumnOrdinal()) .getName(), expectedColumnName); assertEquals( rco.isDerived(), expectedDerived); }
public static void checkColumnOrigin( RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); assertEquals( Iterables.getLast(actualTableName), expectedTableName); assertEquals( actualTable.getRowType() .getFieldList() .get(rco.getOriginColumnOrdinal()) .getName(), expectedColumnName); assertEquals( rco.isDerived(), expectedDerived); }