Skip to content
Draft
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 @@ -3331,6 +3331,17 @@ private void flattenParsedPattern(

private void buildExpandRelNode(
RexInputRef arrayFieldRex, String arrayFieldName, String alias, CalcitePlanContext context) {
// Validate that the field is an array type.
// Only nested array fields are supported by expand command.
RelDataType fieldType = arrayFieldRex.getType();
if (fieldType.getSqlTypeName() != SqlTypeName.ARRAY) {
throw new UnsupportedOperationException(
String.format(
"Expand command only supports nested array fields. "
+ "Field '%s' has type '%s' which is not a nested array.",
arrayFieldName, fieldType.getSqlTypeName()));
}

// 3. Capture the outer row in a CorrelationId
Holder<RexCorrelVariable> correlVariable = Holder.empty();
context.relBuilder.variable(correlVariable::set);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
setup:
- do:
indices.create:
index: test-idx-5065
body:
settings:
number_of_shards: 1
mappings:
properties:
nums:
type: long
- do:
index:
index: test-idx-5065
id: 1
refresh: true
body:
nums: [1, 2, 3]
- do:
query.settings:
body:
transient:
plugins.calcite.enabled: true
---
teardown:
- do:
query.settings:
body:
transient:
plugins.calcite.enabled: false
- do:
indices.delete:
index: test-idx-5065
ignore_unavailable: true

---
"Expand on scalar type should fail with clear error message":
- do:
catch: bad_request
ppl:
body:
query: 'source=test-idx-5065 | expand nums'
- match: { error.type: "UnsupportedOperationException" }
- match: { error.reason: "/.*Expand command only works on array types.*/" }
- match: { error.details: "/.*nums.*BIGINT.*/" }
Loading