@@ -28,12 +28,50 @@ To run these you will need:
2828
2929## Creating a Substrait Plan from SQL
3030
31- To run [ ` FromSql.java ` ] ( ./src/main/java/io/substrait/examples/FromSql.java ) from the root of this repository. ` subtrait.plan ` is the name of file written.
31+ To run [ ` FromSql.java ` ] ( ./src/main/java/io/substrait/examples/FromSql.java ) from the root of this repository. ` subtrait.plan ` is the name of file written. It will output to stdout the text format of the protobuf for information; it's quite length so has been abbreviated here.
3232
3333``` bash
3434 ./gradlew examples:isthmus-api:run --args " FromSql substrait.plan"
3535> Task :examples:isthmus-api:run
36- Plan{version=Version{major=0, minor=77, patch=0, producer=isthmus}, roots=[Root{input=Sort{input=Aggregate{input=Project{remap=Remap{indices=[15]}, input=Filter{input=Join{left=NamedScan{initialSchema=NamedStruct{struct=Struct{nullable=false, fields=[VarChar{nullable=true, length=15}, VarChar{nullable=true, length=40}, VarChar{nullable=true, length=40}, VarChar{nullable=true, length=15}, VarChar{nullable=true, length=15}, I32{nullable=true}, VarChar{nullable=true, length=15}]}, names=[vehicle_id, make, model, colour, fuel_type, cylinder_capacity, first_use_date]}, names=[vehicles]}, right=NamedScan{initialSchema=NamedStruct{struct=Struct{nullable=false, fields=[VarChar{nullable=true, length=15}, VarChar{nullable=true, length=15}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=15}, I32{nullable=true}, VarChar{nullable=true, length=15}]}, names=[test_id, vehicle_id, test_date, test_class, test_type, test_result, test_mileage, postcode_area]}, names=[tests]}, condition=ScalarFunctionInvocation{declaration=equal:any_any, arguments=[FieldReference{segments=[StructField{offset=0}], type=VarChar{nullable=true, length=15}}, FieldReference{segments=[StructField{offset=8}], type=VarChar{nullable=true, length=15}}], options=[], outputType=Bool{nullable=true}}, joinType=INNER}, condition=ScalarFunctionInvocation{declaration=equal:any_any, arguments=[FieldReference{segments=[StructField{offset=12}], type=VarChar{nullable=true, length=15}}, VarCharLiteral{nullable=false, value=P, length=15}], options=[], outputType=Bool{nullable=true}}}, expressions=[FieldReference{segments=[StructField{offset=3}], type=VarChar{nullable=true, length=15}}]}, groupings=[Grouping{expressions=[FieldReference{segments=[StructField{offset=0}], type=VarChar{nullable=true, length=15}}]}], measures=[Measure{function=AggregateFunctionInvocation{declaration=count:, arguments=[], options=[], aggregationPhase=INITIAL_TO_RESULT, sort=[], outputType=I64{nullable=false}, invocation=ALL}}]}, sortFields=[SortField{expr=FieldReference{segments=[StructField{offset=1}], type=Struct{nullable=false, fields=[VarChar{nullable=true, length=15}, I64{nullable=false}]}}, direction=ASC_NULLS_LAST}]}, names=[COLOUR, COLOURCOUNT]}], expectedTypeUrls=[]}
36+ extension_uris {
37+ extension_uri_anchor: 2
38+ uri: " /functions_aggregate_generic.yaml"
39+ }
40+ extension_uris {
41+ extension_uri_anchor: 1
42+ uri: " /functions_comparison.yaml"
43+ }
44+ extensions {
45+ extension_function {
46+ extension_uri_reference: 1
47+ function_anchor: 1
48+ name: " equal:any_any"
49+ extension_urn_reference: 1
50+ }
51+ }
52+ extensions {
53+ extension_function {
54+ extension_uri_reference: 2
55+ function_anchor: 2
56+ name: " count:"
57+ extension_urn_reference: 2
58+ }
59+ }
60+ relations {....}
61+ }
62+ version {
63+ minor_number: 77
64+ producer: " isthmus"
65+ }
66+ extension_urns {
67+ extension_urn_anchor: 1
68+ urn: " extension:io.substrait:functions_comparison"
69+ }
70+ extension_urns {
71+ extension_urn_anchor: 2
72+ urn: " extension:io.substrait:functions_aggregate_generic"
73+ }
74+
3775File written to substrait.plan
3876```
3977
@@ -49,13 +87,43 @@ Please see the code comments for details of how the conversion is done.
4987
5088To run [ ` ToSql.java ` ] ( ./src/main/java/io/substrait/examples/ToSql.java ) from the root of this repository
5189` subtrait.plan ` is the name of file to be read - and probably will be the first created with ` FromSql ` .
52-
90+ Again the text format of the protobuf has been abbreviated.
5391``` bash
5492./gradlew examples:isthmus-api:run --args " ToSql substrait.plan"
5593
5694> Task :examples:isthmus-api:run
5795Reading from substrait.plan
58- Plan{version=Version{major=0, minor=77, patch=0, producer=isthmus}, roots=[Root{input=Sort{input=Aggregate{input=Project{remap=Remap{indices=[15]}, input=Filter{input=Join{left=NamedScan{initialSchema=NamedStruct{struct=Struct{nullable=false, fields=[VarChar{nullable=true, length=15}, VarChar{nullable=true, length=40}, VarChar{nullable=true, length=40}, VarChar{nullable=true, length=15}, VarChar{nullable=true, length=15}, I32{nullable=true}, VarChar{nullable=true, length=15}]}, names=[vehicle_id, make, model, colour, fuel_type, cylinder_capacity, first_use_date]}, names=[vehicles]}, right=NamedScan{initialSchema=NamedStruct{struct=Struct{nullable=false, fields=[VarChar{nullable=true, length=15}, VarChar{nullable=true, length=15}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=20}, VarChar{nullable=true, length=15}, I32{nullable=true}, VarChar{nullable=true, length=15}]}, names=[test_id, vehicle_id, test_date, test_class, test_type, test_result, test_mileage, postcode_area]}, names=[tests]}, condition=ScalarFunctionInvocation{declaration=equal:any_any, arguments=[FieldReference{segments=[StructField{offset=0}], type=VarChar{nullable=true, length=15}}, FieldReference{segments=[StructField{offset=8}], type=VarChar{nullable=true, length=15}}], options=[], outputType=Bool{nullable=true}}, joinType=INNER}, condition=ScalarFunctionInvocation{declaration=equal:any_any, arguments=[FieldReference{segments=[StructField{offset=12}], type=VarChar{nullable=true, length=15}}, VarCharLiteral{nullable=false, value=P, length=15}], options=[], outputType=Bool{nullable=true}}}, expressions=[FieldReference{segments=[StructField{offset=3}], type=VarChar{nullable=true, length=15}}]}, groupings=[Grouping{expressions=[FieldReference{segments=[StructField{offset=0}], type=VarChar{nullable=true, length=15}}]}], measures=[Measure{function=AggregateFunctionInvocation{declaration=count:, arguments=[], options=[], aggregationPhase=INITIAL_TO_RESULT, sort=[], outputType=I64{nullable=false}, invocation=ALL}}]}, sortFields=[SortField{expr=FieldReference{segments=[StructField{offset=1}], type=I64{nullable=false}}, direction=ASC_NULLS_LAST}]}, names=[COLOUR, COLOURCOUNT]}], expectedTypeUrls=[]}
96+ extension_uris {
97+ extension_uri_anchor: 2
98+ uri: " /functions_aggregate_generic.yaml"
99+ }
100+ extension_uris {
101+ extension_uri_anchor: 1
102+ uri: " /functions_comparison.yaml"
103+ }
104+ extensions {
105+ extension_function {
106+ extension_uri_reference: 1
107+ function_anchor: 1
108+ name: " equal:any_any"
109+ extension_urn_reference: 1
110+ }
111+ }
112+ extensions {....}
113+ relations {....}
114+ version {
115+ minor_number: 77
116+ producer: " isthmus"
117+ }
118+ extension_urns {
119+ extension_urn_anchor: 1
120+ urn: " extension:io.substrait:functions_comparison"
121+ }
122+ extension_urns {
123+ extension_urn_anchor: 2
124+ urn: " extension:io.substrait:functions_aggregate_generic"
125+ }
126+
59127
60128SELECT ` t2` .` colour0` AS ` COLOUR` , ` t2` .` $f1 ` AS ` COLOURCOUNT`
61129FROM (SELECT ` vehicles` .` colour` AS ` colour0` , COUNT(* ) AS ` $f1 `
0 commit comments