substrait-io / substrait-validator

Apache License 2.0
7 stars 6 forks source link

Support nested expressions #258

Open EpsilonPrime opened 1 month ago

EpsilonPrime commented 1 month ago

Nested expressions were added to Substrait in https://github.com/substrait-io/substrait/pull/351 (part of release 0.36.0). When given a plan with a nested expression, the validator complains that nested is not one of the valid expression types (which is expected because the validator currently only supports release 0.20.0).

Fatal error:
  Failed to parse relations field: Failed to parse input field: Failed to parse expressions field: Message type "substrait.Expression" has no field named "nested" at "Plan.relations[0].root.input.project.expressions[0]".
   Available Fields(except extensions): "['literal', 'selection', 'scalarFunction', 'windowFunction', 'ifThen', 'switchExpression', 'singularOrList', 'multiOrList', 'cast', 'subquery', 'enum']"...
{
  "relations": [
    {
      "root": {
        "input": {
          "project": {
            "input": {
              "read": {
                "baseSchema": {
                  "names": [
                    "s_suppkey",
                    "s_name",
                    "s_address",
                    "s_nationkey",
                    "s_phone",
                    "s_acctbal",
                    "s_comment"
                  ],
                  "struct": {
                    "types": [
                      {
                        "i64": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "string": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "string": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "i32": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "string": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "decimal": {
                          "scale": 2,
                          "precision": 15,
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "string": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      }
                    ],
                    "nullability": "NULLABILITY_REQUIRED"
                  }
                },
                "projection": {
                  "select": {
                    "structItems": [
                      {
                        "field": 1
                      },
                      {
                        "field": 5
                      }
                    ]
                  },
                  "maintainSingularStruct": true
                },
                "namedTable": {
                  "names": [
                    "supplier"
                  ]
                }
              }
            },
            "expressions": [
              {
                "nested": {
                  "nullable": true,
                  "struct": {
                    "fields": [
                      {
                        "selection": {
                          "directReference": {
                            "structField": {}
                          },
                          "rootReference": {}
                        }
                      },
                      {
                        "selection": {
                          "directReference": {
                            "structField": {
                              "field": 1
                            }
                          },
                          "rootReference": {}
                        }
                      }
                    ]
                  }
                }
              }
            ]
          }
        },
        "names": [
          "supplier",
          "name",
          "acctbal"
        ]
      }
    }
  ],
  "version": {
    "minorNumber": 48,
    "producer": "hand-generated"
  }
}