/** * Gets all partitions of a table by using direct SQL queries. * @param dbName Metastore db name. * @param tblName Metastore table name. * @param max The maximum number of partitions to return. * @return List of partitions. */ public List<Partition> getPartitions( String dbName, String tblName, Integer max) throws MetaException { return getPartitionsViaSqlFilterInternal(dbName, tblName, null, null, new ArrayList<String>(), new ArrayList<String>(), max); }
/** * Gets all partitions of a table by using direct SQL queries. * @param dbName Metastore db name. * @param tblName Metastore table name. * @param max The maximum number of partitions to return. * @return List of partitions. */ public List<Partition> getPartitions( String dbName, String tblName, Integer max) throws MetaException { return getPartitionsViaSqlFilterInternal(dbName, tblName, null, null, new ArrayList<String>(), new ArrayList<String>(), max); }
/** * Gets partitions by using direct SQL queries. * @param dbName Metastore db name. * @param tblName Metastore table name. * @param partNames Partition names to get. * @return List of partitions. */ public List<Partition> getPartitionsViaSqlFilter( String dbName, String tblName, List<String> partNames) throws MetaException { String list = repeat(",?", partNames.size()).substring(1); return getPartitionsViaSqlFilterInternal(dbName, tblName, "and \"PARTITIONS\".\"PART_NAME\" in (" + list + ")" , partNames, new ArrayList<String>()); }
/** * Gets partitions by using direct SQL queries. * @param dbName Metastore db name. * @param tblName Metastore table name. * @param parser The parsed filter from which the SQL filter will be generated. * @return List of partitions. */ public List<Partition> getPartitionsViaSqlFilter(Table table, String dbName, String tblName, FilterParser parser) throws MetaException { List<String> params = new ArrayList<String>(), joins = new ArrayList<String>(); String sqlFilter = (parser == null) ? null : PartitionFilterGenerator.generateSqlFilter(table, parser.tree, params, joins); return getPartitionsViaSqlFilterInternal(dbName, tblName, sqlFilter, params, joins); }
/** * Gets partitions by using direct SQL queries. * Note that batching is not needed for this method - list of names implies the batch size; * @param dbName Metastore db name. * @param tblName Metastore table name. * @param partNames Partition names to get. * @return List of partitions. */ public List<Partition> getPartitionsViaSqlFilter( String dbName, String tblName, List<String> partNames) throws MetaException { if (partNames.isEmpty()) { return new ArrayList<Partition>(); } return getPartitionsViaSqlFilterInternal(dbName, tblName, null, "\"PARTITIONS\".\"PART_NAME\" in (" + makeParams(partNames.size()) + ")", partNames, new ArrayList<String>(), null); }
/** * Gets partitions by using direct SQL queries. * Note that batching is not needed for this method - list of names implies the batch size; * @param dbName Metastore db name. * @param tblName Metastore table name. * @param partNames Partition names to get. * @return List of partitions. */ public List<Partition> getPartitionsViaSqlFilter( String dbName, String tblName, List<String> partNames) throws MetaException { if (partNames.isEmpty()) { return new ArrayList<Partition>(); } return getPartitionsViaSqlFilterInternal(dbName, tblName, null, "\"PARTITIONS\".\"PART_NAME\" in (" + makeParams(partNames.size()) + ")", partNames, new ArrayList<String>(), null); }
/** * 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); }