/** * Gets partitions by using direct SQL queries. * @param filter The filter. * @param max The maximum number of partitions to return. * @return List of partitions. */ public List<Partition> getPartitionsViaSqlFilter( SqlFilterForPushdown filter, Integer max) throws MetaException { Boolean isViewTable = isViewTable(filter.table); String catName = filter.table.isSetCatName() ? filter.table.getCatName() : DEFAULT_CATALOG_NAME; List<Long> partitionIds = getPartitionIdsViaSqlFilter(catName, filter.table.getDbName(), filter.table.getTableName(), filter.filter, filter.params, filter.joins, max); if (partitionIds.isEmpty()) { return Collections.emptyList(); // no partitions, bail early. } return Batchable.runBatched(batchSize, partitionIds, new Batchable<Long, Partition>() { @Override public List<Partition> run(List<Long> input) throws MetaException { return getPartitionsFromPartitionIds(catName, filter.table.getDbName(), filter.table.getTableName(), isViewTable, input, Collections.emptyList()); } }); }
isView = isViewTable(catName, dbName, tblName);
Boolean isView = isViewTable(tbl); if (isView == null) { isView = isViewTable(catName, dbName, tblName);
/** * Gets partitions by using direct SQL queries. * @param table The table. * @param tree The expression tree from which the SQL filter will be derived. * @param max The maximum number of partitions to return. * @return List of partitions. Null if SQL filter cannot be derived. */ public List<Partition> getPartitionsViaSqlFilter( Table table, ExpressionTree tree, Integer max) throws MetaException { assert tree != null; List<Object> params = new ArrayList<Object>(); List<String> joins = new ArrayList<String>(); // Derby and Oracle do not interpret filters ANSI-properly in some cases and need a workaround. boolean dbHasJoinCastBug = (dbType == DB.DERBY || dbType == DB.ORACLE); String sqlFilter = PartitionFilterGenerator.generateSqlFilter( table, tree, params, joins, dbHasJoinCastBug); if (sqlFilter == null) { return null; // Cannot make SQL filter to push down. } Boolean isViewTable = isViewTable(table); return getPartitionsViaSqlFilterInternal(table.getDbName(), table.getTableName(), isViewTable, sqlFilter, params, joins, max); }
/** * Gets partitions by using direct SQL queries. * @param table The table. * @param tree The expression tree from which the SQL filter will be derived. * @param max The maximum number of partitions to return. * @return List of partitions. Null if SQL filter cannot be derived. */ public List<Partition> getPartitionsViaSqlFilter( Table table, ExpressionTree tree, Integer max) throws MetaException { assert tree != null; List<Object> params = new ArrayList<Object>(); List<String> joins = new ArrayList<String>(); // Derby and Oracle do not interpret filters ANSI-properly in some cases and need a workaround. boolean dbHasJoinCastBug = (dbType == DB.DERBY || dbType == DB.ORACLE); String sqlFilter = PartitionFilterGenerator.generateSqlFilter( table, tree, params, joins, dbHasJoinCastBug); if (sqlFilter == null) { return null; // Cannot make SQL filter to push down. } Boolean isViewTable = isViewTable(table); return getPartitionsViaSqlFilterInternal(table.getDbName(), table.getTableName(), isViewTable, sqlFilter, params, joins, max); }
isView = isViewTable(dbName, tblName);
isView = isViewTable(dbName, tblName);