Skip to content

Corrupt proto files #441

Description

@andrewthad

Here is an example of an attempt to filter on a u64 column in an Apache Arrow file:

version:
  majorNumber: 0
  minorNumber: 57
  patchNumber: 1
extensionUris:
- extensionUriAnchor: 1
  uri: https://raw.githubusercontent.com/apache/arrow/refs/heads/main/format/substrait/extension_types.yaml
- extensionUriAnchor: 2
  uri: https://raw.githubusercontent.com/substrait-io/substrait/refs/heads/main/extensions/functions_comparison.yaml
extensions:
- extensionType:
    typeAnchor: 100
    name: 'u32'
    extensionUriReference: 1
- extensionType:
    typeAnchor: 101
    name: 'u64'
    extensionUriReference: 1
- extensionFunction:
    functionAnchor: 200
    name: 'gt'
    extensionUriReference: 2
relations:
- root:
    names:
      - "source_ip"
      - "source_bytes"
    input:
      read:
        namedTable:
          names:
          - traffic
        baseSchema:
          names:
          - source_ip
          - source_bytes
          struct:
            nullability: NULLABILITY_REQUIRED
            types:
            - userDefined:
                typeReference: 100
                nullability: NULLABILITY_REQUIRED
            - userDefined:
                typeReference: 101
                nullability: NULLABILITY_REQUIRED

When I validate with ``, I get a bunch of warnings like this:

Warning (code 0001):
  at plan.extension_uris[1].uri.data.scalar_functions[22]:
  not yet implemented: the following child nodes were not recognized by the validator: description, impls, name (code 0001)

Which seems fine. But when I try to go one step further and convert this yaml to a protobuf, it gets weird. Here's the command I'm using:

../bin/substrait-validator --uri-depth 2 --out-type proto --out-file simpletraffic.proto simpletraffic.yaml

Same warnings, but the proto file that substrait-validator creates is corrupt. It won't round trip with ../bin/substrait-validator --uri-depth 2 simpletraffic.proto, failing with:

Error (code 1001):
  at plan:
  failed to decode Protobuf message: SimpleExtensionUri.extension_uri_anchor: Plan.extension_uris: invalid wire type: LengthDelimited (expected Varint) (code 1001)

Error (code 1002):
  at plan:
  missing required protobuf field: version (code 1002)

Fatal error:
  plan is invalid

Checking the proto file with xxd, I can see that it looks like error and warning messages are interleaved with the binary data:

000055b0: 796e 6f74 2079 6574 2069 6d70 6c65 6d65  ynot yet impleme
000055c0: 6e74 6564 3a20 7468 6520 666f 6c6c 6f77  nted: the follow
000055d0: 696e 6720 6368 696c 6420 6e6f 6465 7320  ing child nodes 
000055e0: 7765 7265 206e 6f74 2072 6563 6f67 6e69  were not recogni
000055f0: 7a65 6420 6279 2074 6865 2076 616c 6964  zed by the valid
00005600: 6174 6f72 3a20 6465 7363 7269 7074 696f  ator: descriptio
00005610: 6e2c 2069 6d70 6c73 2c20 6e61 6d65 2028  n, impls, name (
00005620: 636f 6465 2030 3030 3129 2a4b 0a04 706c  code 0001)*K..pl
00005630: 616e 1214 1212 0a0e 6578 7465 6e73 696f  an......extensio
00005640: 6e5f 7572 6973 1001 1207 0a05 0a03 7572  n_uris........ur

That's not what I would expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions