Representation of a SHOW FILES statement. Acceptable syntax: SHOW FILES IN [dbName.]tableName [PARTITION(key=value,...)]
| 52 | * |
| 53 | */ |
| 54 | public class ShowFilesStmt extends StatementBase implements SingleTableStmt { |
| 55 | private final TableName tableName_; |
| 56 | |
| 57 | // Show files for all the partitions if this is null. |
| 58 | private final PartitionSet partitionSet_; |
| 59 | |
| 60 | // Set during analysis. |
| 61 | protected FeTable table_; |
| 62 | |
| 63 | // File paths selected by Iceberg's partition filtering |
| 64 | private List<String> icebergFilePaths_; |
| 65 | |
| 66 | public ShowFilesStmt(TableName tableName, PartitionSet partitionSet) { |
| 67 | tableName_ = Preconditions.checkNotNull(tableName); |
| 68 | partitionSet_ = partitionSet; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public String toSql(ToSqlOptions options) { |
| 73 | StringBuilder strBuilder = new StringBuilder(); |
| 74 | strBuilder.append("SHOW FILES IN " + tableName_.toString()); |
| 75 | if (partitionSet_ != null) strBuilder.append(" " + partitionSet_.toSql(options)); |
| 76 | return strBuilder.toString(); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public TableName getTableName() { return tableName_; } |
| 81 | |
| 82 | @Override |
| 83 | public void collectTableRefs(List<TableRef> tblRefs) { |
| 84 | tblRefs.add(new TableRef(tableName_.toPath(), null)); |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public void analyze(Analyzer analyzer) throws AnalysisException { |
| 89 | // Resolve and analyze table ref to register privilege and audit events |
| 90 | // and to allow us to evaluate partition predicates. |
| 91 | TableRef tableRef = new TableRef(tableName_.toPath(), null, Privilege.VIEW_METADATA); |
| 92 | tableRef = analyzer.resolveTableRef(tableRef); |
| 93 | if (tableRef instanceof InlineViewRef) { |
| 94 | throw new AnalysisException(String.format( |
| 95 | "SHOW FILES not allowed on a view: %s", tableName_)); |
| 96 | } |
| 97 | if (tableRef instanceof CollectionTableRef) { |
| 98 | throw new AnalysisException(String.format( |
| 99 | "SHOW FILES not allowed on a nested collection: %s", tableName_)); |
| 100 | } |
| 101 | table_ = tableRef.getTable(); |
| 102 | Preconditions.checkNotNull(table_); |
| 103 | if (!(table_ instanceof FeFsTable) && !(table_ instanceof FeShowFileStmtSupport)) { |
| 104 | throw new AnalysisException("SHOW FILES is applicable only to file-based tables."); |
| 105 | } |
| 106 | tableRef.analyze(analyzer); |
| 107 | |
| 108 | // Analyze the partition spec, if one was specified. |
| 109 | if (partitionSet_ != null) { |
| 110 | if (table_ instanceof FeShowFileStmtSupport) { |
| 111 | FeShowFileStmtSupport showFileStmtSupport = (FeShowFileStmtSupport) table_; |
nothing calls this directly
no outgoing calls
no test coverage detected