Skip to content
Merged
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 @@ -186,11 +186,10 @@ public static RelDataType convertExprTypeToRelDataType(ExprType fieldType, boole
return TYPE_FACTORY.createArrayType(
TYPE_FACTORY.createSqlType(SqlTypeName.ANY, nullable), -1);
case STRUCT:
// TODO: should use RelRecordType instead of MapSqlType here
// https://github.com/opensearch-project/sql/issues/3459
final RelDataType relKey = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR);
// TODO: should we provide more precise type here?
return TYPE_FACTORY.createMapType(
relKey, TYPE_FACTORY.createSqlType(SqlTypeName.BINARY), nullable);
relKey, TYPE_FACTORY.createSqlType(SqlTypeName.ANY), nullable);
case UNKNOWN:
default:
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
setup:
- do:
query.settings:
body:
transient:
plugins.calcite.enabled : true

- do:
indices.create:
index: test
body:
mappings:
properties:
parent_field:
properties:
child_field:
type: integer

- do:
bulk:
index: test
refresh: true
body:
- '{"index": {}}'
- '{ "parent_field": { "child_field": 4 } }'
- '{"index": {}}'
- '{ "parent_field": { "child_field": 3 } }'
- '{"index": {}}'
- '{ "parent_field": { "child_field": 2 } }'
- '{"index": {}}'
- '{ "parent_field": { "child_field": 1 } }'
- '{"index": {}}'
- '{ "parent_field": { "child_field": 5 } }'

---
teardown:
- do:
query.settings:
body:
transient:
plugins.calcite.enabled : false

---
"Access to nested field after field command":
- skip:
features:
- headers
- allowed_warnings

- do:
headers:
Content-Type: 'application/json'
ppl:
body:
query: source=test | fields parent_field | sort parent_field.child_field | head 3

- match: { total: 3 }
- match: { schema: [ { "name": "parent_field", "type": "struct" } ] }
- match: { datarows: [ [ {"child_field": 1} ], [ {"child_field": 2} ], [ {"child_field": 3} ] ] }
Loading