simhadri-g commented on code in PR #4346: URL: https://github.com/apache/hive/pull/4346#discussion_r1235688240
########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java: ########## @@ -1433,4 +1445,54 @@ Boolean hasAppendsOnly(Iterable<Snapshot> snapshots, SnapshotContext since) { return null; } + + @Override + public List<String> showPartitions(DDLOperationContext context, org.apache.hadoop.hive.ql.metadata.Table hmstbl) + throws HiveException { + Configuration confs = context.getConf(); + Path path = new Path(hmstbl.getParameters().get(Constants.METADATA_LOCATION)); + JobConf job = HiveTableUtil.getPartJobConf(confs, path, hmstbl); + Class<? extends InputFormat> formatter = hmstbl.getInputFormatClass(); + + try { + InputFormat inputFormat = FetchOperator.getInputFormatFromCache(formatter, job); + InputSplit[] splits = inputFormat.getSplits(job, 1); + try (RecordReader<WritableComparable, Writable> reader = inputFormat.getRecordReader(splits[0], job, + Reporter.NULL)) { + return getParts(context, job, reader, hmstbl); + } + } catch (Exception e) { + throw new HiveException(e, ErrorMsg.GENERIC_ERROR, + "show partitions for table " + hmstbl.getTableName() + ". " + ErrorMsg.TABLE_NOT_PARTITIONED + + " or the table is empty "); + } + } + + private List<String> getParts(DDLOperationContext context, Configuration job, Review Comment: Fixed ########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java: ########## @@ -1433,4 +1445,54 @@ Boolean hasAppendsOnly(Iterable<Snapshot> snapshots, SnapshotContext since) { return null; } + + @Override + public List<String> showPartitions(DDLOperationContext context, org.apache.hadoop.hive.ql.metadata.Table hmstbl) + throws HiveException { + Configuration confs = context.getConf(); + Path path = new Path(hmstbl.getParameters().get(Constants.METADATA_LOCATION)); + JobConf job = HiveTableUtil.getPartJobConf(confs, path, hmstbl); + Class<? extends InputFormat> formatter = hmstbl.getInputFormatClass(); + + try { + InputFormat inputFormat = FetchOperator.getInputFormatFromCache(formatter, job); + InputSplit[] splits = inputFormat.getSplits(job, 1); + try (RecordReader<WritableComparable, Writable> reader = inputFormat.getRecordReader(splits[0], job, + Reporter.NULL)) { + return getParts(context, job, reader, hmstbl); + } + } catch (Exception e) { + throw new HiveException(e, ErrorMsg.GENERIC_ERROR, + "show partitions for table " + hmstbl.getTableName() + ". " + ErrorMsg.TABLE_NOT_PARTITIONED + + " or the table is empty "); + } + } + + private List<String> getParts(DDLOperationContext context, Configuration job, + RecordReader<WritableComparable, Writable> reader, org.apache.hadoop.hive.ql.metadata.Table hmstbl) + throws Exception { + + List<String> parts = Lists.newArrayList(); + Writable value = reader.createValue(); + WritableComparable key = reader.createKey(); + + try (FetchFormatter fetcher = new DefaultFetchFormatter()) { + fetcher.initialize(job, HiveTableUtil.getSerializationProps()); + org.apache.hadoop.hive.ql.metadata.Table metaDataPartTable = + context.getDb().getTable(hmstbl.getDbName(), hmstbl.getTableName(), "partitions", true); + Deserializer currSerDe = metaDataPartTable.getDeserializer(); + ObjectMapper mapper = new ObjectMapper(); + Table tbl = getTable(hmstbl); + Review Comment: Fixed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org