Skip to content

Conversation

@sandeshkr419
Copy link

@sandeshkr419 sandeshkr419 commented Jan 22, 2026

Description

Resolves object type handling when nested fields are present in mappings.
Basically try to skip including the outer field in schema and not the nested flattened out fields.

Caused by: java.sql.SQLException: exception while executing query: Unable to convert the type ANY
        at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
        at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:579)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeQuery(AvaticaPreparedStatement.java:137)
        at org.opensearch.sql.opensearch.executor.OpenSearchExecutionEngine.lambda$execute$6(OpenSearchExecutionEngine.java:213)
        ... 17 more
  • Tested queries on the flattened nested objects
  • Tested queries on other field types which were returning errors previously.
  • Tested group-by as well on flattened objects
curl "localhost:9200/test-grab-index/_mappings?pretty"

{
  "test-grab-index" : {
    "mappings" : {
      "dynamic" : "false",
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "additional_data" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "app_name" : {
          "type" : "keyword"
        },
        "auth" : {
          "properties" : {
            "metadata" : {
              "properties" : {
                "instance_id" : {
                  "type" : "keyword"
                },
                "role" : {
                  "type" : "keyword"
                }
              }
            }
          }
        },
        "availability_zone" : {
          "type" : "keyword"
        },
        "class" : {
          "type" : "keyword"
        },
        "common_booking_code" : {
          "type" : "keyword"
        },
        "common_client" : {
          "type" : "keyword"
        },
        "common_client_ip" : {
          "type" : "keyword"
        },
        "common_driver_id" : {
          "type" : "long"
        },
        "common_endpoint" : {
          "type" : "keyword"
        },
        "common_endpoint_elapsed" : {
          "type" : "long"
        },
        "common_error" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "common_error_type" : {
          "type" : "keyword"
        },
        "common_eta" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "common_http_url" : {
          "type" : "keyword"
        },
        "common_merchant_id" : {
          "type" : "keyword"
        },
        "common_order_id" : {
          "type" : "keyword"
        },
        "common_passenger_id" : {
          "type" : "long"
        },
        "common_provider" : {
          "type" : "keyword"
        },
        "common_reference" : {
          "type" : "keyword"
        },
        "common_region" : {
          "type" : "keyword"
        },
        "common_request" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "common_request_id" : {
          "type" : "keyword"
        },
        "common_response" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "common_service" : {
          "type" : "keyword"
        },
        "common_trace_id" : {
          "type" : "keyword"
        },
        "common_user" : {
          "type" : "keyword"
        },
        "common_vehicle_type" : {
          "type" : "long"
        },
        "event_type" : {
          "type" : "keyword"
        },
        "gopoi_accuracy" : {
          "type" : "double"
        },
        "gopoi_keyword" : {
          "type" : "keyword"
        },
        "gopoi_type" : {
          "type" : "keyword"
        },
        "gopoi_xcountry" : {
          "type" : "keyword"
        },
        "hostname" : {
          "type" : "keyword"
        },
        "invalid_data" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "jaya_rental_agreement_id" : {
          "type" : "long"
        },
        "jaya_user" : {
          "type" : "keyword"
        },
        "log_level" : {
          "type" : "keyword"
        },
        "log_write_epoch" : {
          "type" : "long"
        },
        "message" : {
          "type" : "text",
          "analyzer" : "custom_message_analyzer"
        },
        "orbital_location_id" : {
          "type" : "long"
        },
        "pipeline_error" : {
          "type" : "text",
          "index" : false
        },
        "request" : {
          "properties" : {
            "headers" : {
              "properties" : {
                "x-forwarded-for" : {
                  "type" : "keyword"
                }
              }
            },
            "operation" : {
              "type" : "keyword"
            },
            "path" : {
              "type" : "keyword"
            }
          }
        },
        "source" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "stacktrace" : {
          "type" : "text",
          "analyzer" : "standard"
        },
        "tags" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "ucm_config_key" : {
          "type" : "keyword"
        },
        "ucm_operation" : {
          "type" : "keyword"
        },
        "ucm_repository" : {
          "type" : "keyword"
        },
        "ucm_running_env" : {
          "type" : "keyword"
        },
        "vpc_name" : {
          "type" : "keyword"
        }
      }
    }
  }
}
 curl -X POST "http://localhost:9200/_plugins/_ppl" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "source=test-grab-index | stats dc(auth.metadata.instance_id) as min"
  }'
{
  "schema": [
    {
      "name": "min",
      "type": "bigint"
    }
  ],
  "datarows": [
    [
      6
    ]
  ],
  "total": 1,
  "size": 1
}
curl -X POST "http://localhost:9200/_plugins/_ppl" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "source=test-grab-index | stats min(common_passenger_id) as min"
  }'
{
  "schema": [
    {
      "name": "min",
      "type": "bigint"
    }
  ],
  "datarows": [
    [
      1001
    ]
  ],
  "total": 1,
  "size": 1
}
curl -X POST "http://localhost:9200/_plugins/_ppl" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "source=test-grab-index | stats min(common_passenger_id) by auth.metadata.instance_id"
  }'
{
  "schema": [
    {
      "name": "min(common_passenger_id)",
      "type": "bigint"
    },
    {
      "name": "auth.metadata.instance_id",
      "type": "string"
    }
  ],
  "datarows": [
    [
      1001,
      "i-001"
    ],
    [
      1002,
      "i-002"
    ],
    [
      1003,
      "i-003"
    ],
    [
      1004,
      "i-004"
    ],
    [
      1005,
      "i-005"
    ],
    [
      1006,
      "i-006"
    ]
  ],
  "total": 6,
  "size": 6
}

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants