Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2075,11 +2075,31 @@ public boolean isPartitioned(org.apache.hadoop.hive.ql.metadata.Table hmsTable)
return table.spec().isPartitioned();
}

private boolean isPartitionPresent(org.apache.hadoop.hive.ql.metadata.Table table,
Map<String, String> partitionSpec) throws SemanticException {
try {
List<String> partNames = getPartitionNames(table, partitionSpec);
for (String partName : partNames) {
if (Warehouse.makeSpecFromName(partName).size() == partitionSpec.size()) {
return true;
}
}
} catch (HiveException e) {
return false;
} catch (MetaException e) {
throw new SemanticException("Unable to construct spec for partition name due to: ", e);
}
return false;
}

@Override
public Partition getPartition(org.apache.hadoop.hive.ql.metadata.Table table,
Map<String, String> partitionSpec, RewritePolicy policy) throws SemanticException {
validatePartSpec(table, partitionSpec, policy);
try {
if (!isPartitionPresent(table, partitionSpec)) {
return null;
}
String partName = Warehouse.makePartName(partitionSpec, false);
return new DummyPartition(table, partName, partitionSpec);
} catch (MetaException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ public void testCreatePartitionedTableWithColumnComments() {

List<Object[]> rows = shell.executeStatement("DESCRIBE default.partitioned_with_comment_table");
List<Types.NestedField> columns = icebergTable.schema().columns();
// The partition transform information is 3 extra lines, and 2 more line for the columns
Assert.assertEquals(columns.size() + 5, rows.size());
// The partition transform information and partition information is 6 extra lines, and 4 more line for the columns
Assert.assertEquals(columns.size() + 10, rows.size());
for (int i = 0; i < columns.size(); i++) {
Types.NestedField field = columns.get(i);
Assert.assertArrayEquals(new Object[] {field.name(), HiveSchemaUtil.convert(field.type()).getTypeName(),
Expand Down Expand Up @@ -1316,8 +1316,8 @@ public void testAlterTableRenamePartitionColumn() throws Exception {
shell.executeStatement("ALTER TABLE default.customers SET PARTITION SPEC (region, city)");

List<Object[]> result = shell.executeStatement("DESCRIBE default.customers");
Assert.assertArrayEquals(new String[] {"region", "IDENTITY", null}, result.get(8));
Assert.assertArrayEquals(new String[] {"city", "IDENTITY", null}, result.get(9));
Assert.assertArrayEquals(new String[] {"region", "IDENTITY", null}, result.get(14));
Assert.assertArrayEquals(new String[] {"city", "IDENTITY", null}, result.get(15));
}

@Test
Expand Down Expand Up @@ -1483,25 +1483,6 @@ public void testMetaHookWithUndefinedAlterOperationType() throws Exception {
metaHook.commitAlterTable(hmsTable, environmentContext);
}

@Test
public void testCommandsWithPartitionClauseThrow() {
TableIdentifier target = TableIdentifier.of("default", "target");
PartitionSpec spec = PartitionSpec.builderFor(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA)
.identity("last_name").build();
testTables.createTable(shell, target.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
spec, FileFormat.PARQUET, ImmutableList.of());

String[] commands = {
"DESCRIBE target PARTITION (last_name='Johnson')"
};

for (String command : commands) {
Assertions.assertThatThrownBy(() -> shell.executeStatement(command))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Using partition spec in query is unsupported");
}
}

@Test
public void testAuthzURIMasked() throws TException, URISyntaxException, InterruptedException {
testAuthzURI(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
drop table if exists ice_t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please combine it with the desc_ice_tbl_part_spec.q

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please explain what do you mean by combining ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep both test cases in 1 qfile

create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg;
insert into table ice_t values( 5, "hello5" ,6, "hello6");
desc formatted ice_t PARTITION(c=6);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
drop table if exists ice_t;
create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg;
insert into table ice_t values( 5, "hello5" ,6, "hello6");
desc formatted ice_t PARTITION(c=6, d="hello");
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
drop table if exists ice_t;
create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg;

insert into table ice_t values( 1, "hello1" ,2, "hello2" );
insert into table ice_t values( 3, "hello3" ,4, "hello4" );
insert into table ice_t values( 5, "hello5" ,6, "hello6" );

desc extended ice_t PARTITION( c=6, d="hello6" );
desc formatted ice_t PARTITION( c=6, d="hello6" );

alter table ice_t set partition spec ( c, d, b );
insert into table ice_t values( 7, "hello7" , 8 , "hello8" );
desc formatted ice_t PARTITION( c=8 , d="hello8", b="hello7" );
desc formatted ice_t PARTITION( c=4 , d="hello4" );
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PREHOOK: query: drop table if exists ice_t
PREHOOK: type: DROPTABLE
PREHOOK: Output: database:default
POSTHOOK: query: drop table if exists ice_t
POSTHOOK: type: DROPTABLE
POSTHOOK: Output: database:default
PREHOOK: query: create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg
PREHOOK: type: CREATETABLE
PREHOOK: Output: database:default
PREHOOK: Output: default@ice_t
POSTHOOK: query: create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@ice_t
PREHOOK: query: insert into table ice_t values( 5, "hello5" ,6, "hello6")
PREHOOK: type: QUERY
PREHOOK: Input: _dummy_database@_dummy_table
PREHOOK: Output: default@ice_t
POSTHOOK: query: insert into table ice_t values( 5, "hello5" ,6, "hello6")
POSTHOOK: type: QUERY
POSTHOOK: Input: _dummy_database@_dummy_table
POSTHOOK: Output: default@ice_t
FAILED: SemanticException [Error 10006]: Partition not found {c=6}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PREHOOK: query: drop table if exists ice_t
PREHOOK: type: DROPTABLE
PREHOOK: Output: database:default
POSTHOOK: query: drop table if exists ice_t
POSTHOOK: type: DROPTABLE
POSTHOOK: Output: database:default
PREHOOK: query: create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg
PREHOOK: type: CREATETABLE
PREHOOK: Output: database:default
PREHOOK: Output: default@ice_t
POSTHOOK: query: create external table ice_t (a int, b string) partitioned by (c int, d string) write locally ordered by a desc stored by iceberg
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@ice_t
PREHOOK: query: insert into table ice_t values( 5, "hello5" ,6, "hello6")
PREHOOK: type: QUERY
PREHOOK: Input: _dummy_database@_dummy_table
PREHOOK: Output: default@ice_t
POSTHOOK: query: insert into table ice_t values( 5, "hello5" ,6, "hello6")
POSTHOOK: type: QUERY
POSTHOOK: Input: _dummy_database@_dummy_table
POSTHOOK: Output: default@ice_t
FAILED: SemanticException [Error 10006]: Partition not found {c=6, d=hello}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ a int
b string
c string

# Partition Information
# col_name data_type comment
b string Transform: identity
c string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -451,6 +456,11 @@ a int
b string
c string

# Partition Information
# col_name data_type comment
b string Transform: identity
c string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -722,6 +732,11 @@ a int
b string
c string

# Partition Information
# col_name data_type comment
b string Transform: identity
c string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -1055,6 +1070,12 @@ b double
c int
d string

# Partition Information
# col_name data_type comment
b double Transform: identity
c int Transform: identity
d string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -1496,6 +1517,12 @@ b double
c int
d string

# Partition Information
# col_name data_type comment
b double Transform: identity
c int Transform: identity
d string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -1937,6 +1964,12 @@ b double
c int
d string

# Partition Information
# col_name data_type comment
b double Transform: identity
c int Transform: identity
d string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ POSTHOOK: Input: default@tbl_orc
a int
b string

# Partition Information
# col_name data_type comment
b string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -413,6 +417,10 @@ POSTHOOK: Input: default@tbl_parquet
a int
b string

# Partition Information
# col_name data_type comment
b string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -764,6 +772,10 @@ POSTHOOK: Input: default@tbl_parquet_int
a int
b int

# Partition Information
# col_name data_type comment
b int Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -1115,6 +1127,10 @@ POSTHOOK: Input: default@tbl_parquet_double
a int
b double

# Partition Information
# col_name data_type comment
b double Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down Expand Up @@ -1412,6 +1428,10 @@ POSTHOOK: Input: default@tbl_avro
a int
b string

# Partition Information
# col_name data_type comment
b string Transform: identity

# Partition Transform Information
# col_name transform_type
b IDENTITY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ a int
b string
c int

# Partition Information
# col_name data_type comment
a int Transform: bucket[16]
b string Transform: truncate[3]

# Partition Transform Information
# col_name transform_type
a BUCKET[16]
Expand Down
Loading