diff --git a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java index 139aac90377c..46bb2322465f 100644 --- a/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java +++ b/plugin/trino-elasticsearch/src/main/java/io/trino/plugin/elasticsearch/ElasticsearchMetadata.java @@ -364,7 +364,7 @@ else if (type instanceof ObjectType) { ImmutableList.Builder decoderFields = ImmutableList.builder(); for (IndexMetadata.Field rowField : objectType.getFields()) { String name = rowField.getName(); - TypeAndDecoder child = toTrino(appendPath(path, name), rowField); + TypeAndDecoder child = toTrino(path, rowField); if (child != null) { decoderFields.add(new RowDecoder.NameAndDescriptor(name, child.getDecoderDescriptor())); diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java index dfba4c8a0695..05ef17e43ee1 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java @@ -1302,6 +1302,37 @@ public void testTimestamps() assertThat(rows.getMaterializedRows()).containsExactlyInAnyOrderElementsOf(expected.getMaterializedRows()); } + @Test + public void testNestedTimestamps() + throws IOException + { + String indexName = "nested_timestamps"; + + @Language("JSON") + String mappings = "" + + "{" + + " \"properties\":{" + + " \"field\": {" + + " \"properties\": {" + + " \"timestamp_column\": { \"type\": \"date\" }" + + " }" + + " }" + + " }" + + "}"; + + createIndex(indexName, mappings); + + index(indexName, ImmutableMap.of("field", ImmutableMap.of("timestamp_column", 0))); + index(indexName, ImmutableMap.of("field", ImmutableMap.of("timestamp_column", "1"))); + index(indexName, ImmutableMap.of("field", ImmutableMap.of("timestamp_column", "1970-01-01T01:01:00+0000"))); + + assertThat(query("SELECT field.timestamp_column FROM " + indexName)) + .matches("VALUES " + + "(TIMESTAMP '1970-01-01 00:00:00.000')," + + "(TIMESTAMP '1970-01-01 00:00:00.001')," + + "(TIMESTAMP '1970-01-01 01:01:00.000')"); + } + @Test public void testScaledFloat() throws Exception