Skip to content
Closed
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 @@ -131,6 +131,7 @@ public Database fromDatabaseInfo(final DatabaseInfo databaseInfo) {
public TableInfo toTableInfo(final QualifiedName name, final Table table) {
final List<FieldSchema> nonPartitionColumns =
(table.getSd() != null) ? table.getSd().getCols() : Collections.emptyList();
log.debug("Hey Size = " + nonPartitionColumns.size());
// add the data fields to the nonPartitionColumns
//ignore all exceptions
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,120 @@ class MetacatSmokeSpec extends Specification {
thrown(MetacatNotSupportedException)
}

@Unroll
def "Test create/get view with nested fields with upper case"() {
given:
def catalogName = 'embedded-fast-hive-metastore'
def databaseName = 'iceberg_db'
def tableName = 'iceberg_table_with_upper_case_nested_fields'
def uri = isLocalEnv ? String.format('file:/tmp/data/') : null
def tableDto = new TableDto(
name: QualifiedName.ofTable(catalogName, databaseName, tableName),
serde: new StorageDto(
owner: 'metacat-test',
inputFormat: 'org.apache.hadoop.mapred.TextInputFormat',
outputFormat: 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',
serializationLib: 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe',
parameters: [
'serialization.format': '1'
],
uri: uri
),
definitionMetadata: null,
dataMetadata: null,
fields: [
new FieldDto(
comment: null,
name: "dateint",
pos: 0,
type: "long",
partition_key: true,
),
new FieldDto(
comment: null,
name: "info",
pos: 1,
partition_key: false,
type: "(name: chararray, address: (NAME: chararray), nestedArray: {(FIELD1: chararray, field2: chararray)})",
)
]
)

def metadataLocation = String.format('/tmp/data/metadata/00000-0b60cc39-438f-413e-96c2-2694d7926529.metadata.json')

if (isIcebergTable) {
def metadata = [common_view: 'true', metadata_location: metadataLocation]
tableDto.setMetadata(metadata)
}
when:
try {api.createDatabase(catalogName, databaseName, new DatabaseCreateRequestDto())
} catch (Exception ignored) {
}
api.createTable(catalogName, databaseName, tableName, tableDto)
def tableDTO = api.getTable(catalogName, databaseName, tableName, true, true, true)

then:
noExceptionThrown()
if (isIcebergTable) {
tableDTO.metadata.get("metadata_location").equals(metadataLocation)
}
tableDTO.getFields().size() == 2
def nestedFieldDto = tableDTO.getFields().find { it.name == "info" }
// assert that the type field also keeps the name fidelity
assert nestedFieldDto.type == "(name: chararray,address: (NAME: chararray),nestedArray: {(FIELD1: chararray,field2: chararray)})" : "The type differ from the expected. They are: $nestedFieldDto.type"

// assert that the json representation keeps the name fidelity
def expectedJsonString = """
{
"type": "row",
"fields": [
{
"name": "name",
"type": "chararray"
},
{
"name": "address",
"type": {
"type": "row",
"fields": [
{
"name": "NAME",
"type": "chararray"
}
]
}
},
{
"name": "nestedArray",
"type": {
"type": "array",
"elementType": {
"type": "row",
"fields": [
{
"name": "FIELD1",
"type": "chararray"
},
{
"name": "field2",
"type": "chararray"
}
]
}
}
}
]
}
"""

JSONAssert.assertEquals(nestedFieldDto.jsonType.toString(), expectedJsonString, false)
JSONAssert.assertEquals("", expectedJsonString, false)
cleanup:
api.deleteTable(catalogName, databaseName, tableName)
where:
isIcebergTable << [true]
}

@Unroll
def "Test create/get table with nested fields with upper case"() {
given:
Expand Down