Apache DataFusion SQL Query Engine
Implement TPCH substrait integration test, support tpch_4 and tpch_5 (#11311)
Lordwormse4b54f6eaea8
diff --git a/datafusion/substrait/src/logical_plan/consumer.rs b/datafusion/substrait/src/logical_plan/consumer.rsindex 03692399e1..905475eaca 100644--- a/datafusion/substrait/src/logical_plan/consumer.rs+++ b/datafusion/substrait/src/logical_plan/consumer.rs@@ -27,12 +27,13 @@ use datafusion::common::{substrait_err, DFSchema, DFSchemaRef,};use datafusion::execution::FunctionRegistry;-use datafusion::logical_expr::expr::{InSubquery, Sort};+use datafusion::logical_expr::expr::{Exists, InSubquery, Sort};use datafusion::logical_expr::{aggregate_function, expr::find_df_window_func, Aggregate, BinaryExpr, Case,EmptyRelation, Expr, ExprSchemable, LogicalPlan, Operator, Projection, Values,};+use substrait::proto::expression::subquery::set_predicate::PredicateOp;use url::Url;use crate::variation_const::{@@ -54,7 +55,7 @@ use datafusion::logical_expr::{use datafusion::prelude::JoinType;use datafusion::sql::TableReference;use datafusion::{- error::{DataFusionError, Result},+ error::Result,logical_expr::utils::split_conjunction,prelude::{Column, SessionContext},scalar::ScalarValue,@@ -1249,10 +1250,7 @@ pub async fn from_substrait_rex(Some(subquery_type) => match subquery_type {SubqueryType::InPredicate(in_predicate) => {if in_predicate.needles.len() != 1 {- Err(DataFusionError::Substrait(- "InPredicate Subquery type must have exactly one Needle expression"- .to_string(),- ))+ substrait_err!("InPredicate Subquery type must have exactly one Needle expression")} else {let needle_expr = &in_predicate.needles[0];let haystack_expr = &in_predicate.haystack;@@ -1297,6 +1295,32 @@ pub async fn from_substrait_rex(outer_ref_columns,})))}+ SubqueryType::SetPredicate(predicate) => {+ match predicate.predicate_op() {+ // exist+ PredicateOp::Exists => {+ let relation = &predicate.tuples;+ let plan = from_substrait_rel(+ ctx,+ &relation.clone().unwrap_or_default(),+ extensions,+ )+ .await?;+ let outer_ref_columns = plan.all_out_ref_exprs();+ Ok(Arc::new(Expr::Exists(Exists::new(+ Subquery {+ subquery: Arc::new(plan),+ outer_ref_columns,+ },+ false,+ ))))+ }+ other_type => substrait_err!(+ "unimplemented type {:?} for set predicate",+ other_type+ ),+ }+ }other_type => {substrait_err!("Subquery type {:?} not implemented", other_type)}diff --git a/datafusion/substrait/tests/cases/consumer_integration.rs b/datafusion/substrait/tests/cases/consumer_integration.rsindex a8bbeb444a..5d565c0378 100644--- a/datafusion/substrait/tests/cases/consumer_integration.rs+++ b/datafusion/substrait/tests/cases/consumer_integration.rs@@ -90,6 +90,40 @@ mod tests {Ok(ctx)}+ async fn create_context_tpch4() -> Result<SessionContext> {+ let ctx = SessionContext::new();++ let registrations = vec![+ ("FILENAME_PLACEHOLDER_0", "tests/testdata/tpch/orders.csv"),+ ("FILENAME_PLACEHOLDER_1", "tests/testdata/tpch/lineitem.csv"),+ ];++ for (table_name, file_path) in registrations {+ register_csv(&ctx, table_name, file_path).await?;+ }++ Ok(ctx)+ }++ async fn create_context_tpch5() -> Result<SessionContext> {+ let ctx = SessionContext::new();++ let registrations = vec![+ ("FILENAME_PLACEHOLDER_0", "tests/testdata/tpch/customer.csv"),+ ("FILENAME_PLACEHOLDER_1", "tests/testdata/tpch/orders.csv"),+ ("FILENAME_PLACEHOLDER_2", "tests/testdata/tpch/lineitem.csv"),+ ("FILENAME_PLACEHOLDER_3", "tests/testdata/tpch/supplier.csv"),+ ("NATION", "tests/testdata/tpch/nation.csv"),+ ("REGION", "tests/testdata/tpch/region.csv"),+ ];++ for (table_name, file_path) in registrations {+ register_csv(&ctx, table_name, file_path).await?;+ }++ Ok(ctx)+ }+#[tokio::test]async fn tpch_test_1() -> Result<()> {let ctx = create_context_tpch1().await?;@@ -180,4 +214,56 @@ mod tests {\n TableScan: FILENAME_PLACEHOLDER_1 projection=[o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment]\n TableScan: FILENAME_PLACEHOLDER_2 projection=[l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment]");Ok(())}++ #[tokio::test]+ async fn tpch_test_4() -> Result<()> {+ let ctx = create_context_tpch4().await?;+ let path = "tests/testdata/tpch_substrait_plans/query_4.json";+ let proto = serde_json::from_reader::<_, Plan>(BufReader::new(+ File::open(path).expect("file not found"),+ ))+ .expect("failed to parse json");+ let plan = from_substrait_plan(&ctx, &proto).await?;+ let plan_str = format!("{:?}", plan);+ assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.o_orderpriority AS O_ORDERPRIORITY, count(Int64(1)) AS ORDER_COUNT\+ \n Sort: FILENAME_PLACEHOLDER_0.o_orderpriority ASC NULLS LAST\+ \n Aggregate: groupBy=[[FILENAME_PLACEHOLDER_0.o_orderpriority]], aggr=[[count(Int64(1))]]\+ \n Projection: FILENAME_PLACEHOLDER_0.o_orderpriority\+ \n Filter: FILENAME_PLACEHOLDER_0.o_orderdate >= CAST(Utf8(\"1993-07-01\") AS Date32) AND FILENAME_PLACEHOLDER_0.o_orderdate < CAST(Utf8(\"1993-10-01\") AS Date32) AND EXISTS (<subquery>)\+ \n Subquery:\+ \n Filter: FILENAME_PLACEHOLDER_1.l_orderkey = FILENAME_PLACEHOLDER_1.l_orderkey AND FILENAME_PLACEHOLDER_1.l_commitdate < FILENAME_PLACEHOLDER_1.l_receiptdate\+ \n TableScan: FILENAME_PLACEHOLDER_1 projection=[l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment]\+ \n TableScan: FILENAME_PLACEHOLDER_0 projection=[o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment]");+ Ok(())+ }++ #[tokio::test]+ async fn tpch_test_5() -> Result<()> {+ let ctx = create_context_tpch5().await?;+ let path = "tests/testdata/tpch_substrait_plans/query_5.json";+ let proto = serde_json::from_reader::<_, Plan>(BufReader::new(+ File::open(path).expect("file not found"),+ ))+ .expect("failed to parse json");++ let plan = from_substrait_plan(&ctx, &proto).await?;+ let plan_str = format!("{:?}", plan);+ assert_eq!(plan_str, "Projection: NATION.n_name AS N_NAME, sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) AS REVENUE\+ \n Sort: sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) DESC NULLS FIRST\+ \n Aggregate: groupBy=[[NATION.n_name]], aggr=[[sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount)]]\+ \n Projection: NATION.n_name, FILENAME_PLACEHOLDER_2.l_extendedprice * (CAST(Int32(1) AS Decimal128(19, 0)) - FILENAME_PLACEHOLDER_2.l_discount)\+ \n Filter: FILENAME_PLACEHOLDER_0.c_custkey = FILENAME_PLACEHOLDER_1.o_custkey AND FILENAME_PLACEHOLDER_2.l_orderkey = FILENAME_PLACEHOLDER_1.o_orderkey AND FILENAME_PLACEHOLDER_2.l_suppkey = FILENAME_PLACEHOLDER_3.s_suppkey AND FILENAME_PLACEHOLDER_0.c_nationkey = FILENAME_PLACEHOLDER_3.s_nationkey AND FILENAME_PLACEHOLDER_3.s_nationkey = NATION.n_nationkey AND NATION.n_regionkey = REGION.r_regionkey AND REGION.r_name = CAST(Utf8(\"ASIA\") AS Utf8) AND FILENAME_PLACEHOLDER_1.o_orderdate >= CAST(Utf8(\"1994-01-01\") AS Date32) AND FILENAME_PLACEHOLDER_1.o_orderdate < CAST(Utf8(\"1995-01-01\") AS Date32)\+ \n Inner Join: Filter: Boolean(true)\+ \n Inner Join: Filter: Boolean(true)\+ \n Inner Join: Filter: Boolean(true)\+ \n Inner Join: Filter: Boolean(true)\+ \n Inner Join: Filter: Boolean(true)\+ \n TableScan: FILENAME_PLACEHOLDER_0 projection=[c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_mktsegment, c_comment]\+ \n TableScan: FILENAME_PLACEHOLDER_1 projection=[o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment]\+ \n TableScan: FILENAME_PLACEHOLDER_2 projection=[l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment]\+ \n TableScan: FILENAME_PLACEHOLDER_3 projection=[s_suppkey, s_name, s_address, s_nationkey, s_phone, s_acctbal, s_comment]\+ \n TableScan: NATION projection=[n_nationkey, n_name, n_regionkey, n_comment]\+ \n TableScan: REGION projection=[r_regionkey, r_name, r_comment]");+ Ok(())+ }}diff --git a/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_4.json b/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_4.jsonnew file mode 100644index 0000000000..6e946cefdd--- /dev/null+++ b/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_4.json@@ -0,0 +1,540 @@+{+ "extensionUris": [{+ "extensionUriAnchor": 4,+ "uri": "/functions_aggregate_generic.yaml"+ }, {+ "extensionUriAnchor": 1,+ "uri": "/functions_boolean.yaml"+ }, {+ "extensionUriAnchor": 2,+ "uri": "/functions_datetime.yaml"+ }, {+ "extensionUriAnchor": 3,+ "uri": "/functions_comparison.yaml"+ }],+ "extensions": [{+ "extensionFunction": {+ "extensionUriReference": 1,+ "functionAnchor": 0,+ "name": "and:bool"+ }+ }, {+ "extensionFunction": {+ "extensionUriReference": 2,+ "functionAnchor": 1,+ "name": "gte:date_date"+ }+ }, {+ "extensionFunction": {+ "extensionUriReference": 2,+ "functionAnchor": 2,+ "name": "lt:date_date"+ }+ }, {+ "extensionFunction": {+ "extensionUriReference": 3,+ "functionAnchor": 3,+ "name": "equal:any1_any1"+ }+ }, {+ "extensionFunction": {+ "extensionUriReference": 4,+ "functionAnchor": 4,+ "name": "count:opt"+ }+ }],+ "relations": [{+ "root": {+ "input": {+ "sort": {+ "common": {+ "direct": {+ }+ },+ "input": {+ "aggregate": {+ "common": {+ "direct": {+ }+ },+ "input": {+ "project": {+ "common": {+ "emit": {+ "outputMapping": [9]+ }+ },+ "input": {+ "filter": {+ "common": {+ "direct": {+ }+ },+ "input": {+ "read": {+ "common": {+ "direct": {+ }+ },+ "baseSchema": {+ "names": ["O_ORDERKEY", "O_CUSTKEY", "O_ORDERSTATUS", "O_TOTALPRICE", "O_ORDERDATE", "O_ORDERPRIORITY", "O_CLERK", "O_SHIPPRIORITY", "O_COMMENT"],+ "struct": {+ "types": [{+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ }, {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ }, {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "i32": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "varchar": {+ "length": 79,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_0",+ "parquet": {}+ }+ ]+ }+ }+ },+ "condition": {+ "scalarFunction": {+ "functionReference": 0,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [{+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [{+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 4+ }+ },+ "rootReference": {+ }+ }+ }+ }, {+ "value": {+ "cast": {+ "type": {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "input": {+ "literal": {+ "fixedChar": "1993-07-01",+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ }]+ }+ }+ }, {+ "value": {+ "scalarFunction": {+ "functionReference": 2,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [{+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 4+ }+ },+ "rootReference": {+ }+ }+ }+ }, {+ "value": {+ "cast": {+ "type": {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "input": {+ "literal": {+ "fixedChar": "1993-10-01",+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ }]+ }+ }+ }, {+ "value": {+ "subquery": {+ "setPredicate": {+ "predicateOp": "PREDICATE_OP_EXISTS",+ "tuples": {+ "filter": {+ "common": {+ "direct": {+ }+ },+ "input": {+ "read": {+ "common": {+ "direct": {+ }+ },+ "baseSchema": {+ "names": ["L_ORDERKEY", "L_PARTKEY", "L_SUPPKEY", "L_LINENUMBER", "L_QUANTITY", "L_EXTENDEDPRICE", "L_DISCOUNT", "L_TAX", "L_RETURNFLAG", "L_LINESTATUS", "L_SHIPDATE", "L_COMMITDATE", "L_RECEIPTDATE", "L_SHIPINSTRUCT", "L_SHIPMODE", "L_COMMENT"],+ "struct": {+ "types": [{+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ }, {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ }, {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ }, {+ "i32": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "fixedChar": {+ "length": 10,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }, {+ "varchar": {+ "length": 44,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_1",+ "parquet": {}+ }+ ]+ }+ }+ },+ "condition": {+ "scalarFunction": {+ "functionReference": 0,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [{+ "value": {+ "scalarFunction": {+ "functionReference": 3,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [{+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {+ }+ }+ }+ }, {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "outerReference": {+ "stepsOut": 1+ }+ }+ }+ }]+ }+ }+ }, {+ "value": {+ "scalarFunction": {+ "functionReference": 2,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [{+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 11+ }+ },+ "rootReference": {+ }+ }+ }+ }, {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 12+ }+ },+ "rootReference": {+ }+ }+ }+ }]+ }+ }+ }]+ }+ }+ }+ }+ }+ }+ }+ }]+ }+ }+ }+ },+ "expressions": [{+ "selection": {+ "directReference": {+ "structField": {+ "field": 5+ }+ },+ "rootReference": {+ }+ }+ }]+ }+ },+ "groupings": [{+ "groupingExpressions": [{+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {+ }+ }+ }]+ }],+ "measures": [{+ "measure": {+ "functionReference": 4,+ "args": [],+ "sorts": [],+ "phase": "AGGREGATION_PHASE_INITIAL_TO_RESULT",+ "outputType": {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "invocation": "AGGREGATION_INVOCATION_ALL",+ "arguments": []+ }+ }]+ }+ },+ "sorts": [{+ "expr": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {+ }+ }+ },+ "direction": "SORT_DIRECTION_ASC_NULLS_LAST"+ }]+ }+ },+ "names": ["O_ORDERPRIORITY", "ORDER_COUNT"]+ }+ }],+ "expectedTypeUrls": []+}diff --git a/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_5.json b/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_5.jsonnew file mode 100644index 0000000000..75b82a305e--- /dev/null+++ b/datafusion/substrait/tests/testdata/tpch_substrait_plans/query_5.json@@ -0,0 +1,1254 @@+{+ "extensionUris": [+ {+ "extensionUriAnchor": 1,+ "uri": "/functions_boolean.yaml"+ },+ {+ "extensionUriAnchor": 4,+ "uri": "/functions_arithmetic_decimal.yaml"+ },+ {+ "extensionUriAnchor": 3,+ "uri": "/functions_datetime.yaml"+ },+ {+ "extensionUriAnchor": 2,+ "uri": "/functions_comparison.yaml"+ }+ ],+ "extensions": [+ {+ "extensionFunction": {+ "extensionUriReference": 1,+ "functionAnchor": 0,+ "name": "and:bool"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 2,+ "functionAnchor": 1,+ "name": "equal:any1_any1"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 3,+ "functionAnchor": 2,+ "name": "gte:date_date"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 3,+ "functionAnchor": 3,+ "name": "lt:date_date"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 4,+ "functionAnchor": 4,+ "name": "multiply:opt_decimal_decimal"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 4,+ "functionAnchor": 5,+ "name": "subtract:opt_decimal_decimal"+ }+ },+ {+ "extensionFunction": {+ "extensionUriReference": 4,+ "functionAnchor": 6,+ "name": "sum:opt_decimal"+ }+ }+ ],+ "relations": [+ {+ "root": {+ "input": {+ "sort": {+ "common": {+ "direct": {}+ },+ "input": {+ "aggregate": {+ "common": {+ "direct": {}+ },+ "input": {+ "project": {+ "common": {+ "emit": {+ "outputMapping": [+ 47,+ 48+ ]+ }+ },+ "input": {+ "filter": {+ "common": {+ "direct": {}+ },+ "input": {+ "join": {+ "common": {+ "direct": {}+ },+ "left": {+ "join": {+ "common": {+ "direct": {}+ },+ "left": {+ "join": {+ "common": {+ "direct": {}+ },+ "left": {+ "join": {+ "common": {+ "direct": {}+ },+ "left": {+ "join": {+ "common": {+ "direct": {}+ },+ "left": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "C_CUSTKEY",+ "C_NAME",+ "C_ADDRESS",+ "C_NATIONKEY",+ "C_PHONE",+ "C_ACCTBAL",+ "C_MKTSEGMENT",+ "C_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "varchar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 40,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 10,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 117,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_0",+ "parquet": {}+ }+ ]+ }+ }+ },+ "right": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "O_ORDERKEY",+ "O_CUSTKEY",+ "O_ORDERSTATUS",+ "O_TOTALPRICE",+ "O_ORDERDATE",+ "O_ORDERPRIORITY",+ "O_CLERK",+ "O_SHIPPRIORITY",+ "O_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "i32": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 79,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_1",+ "parquet": {}+ }+ ]+ }+ }+ },+ "expression": {+ "literal": {+ "boolean": true,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "type": "JOIN_TYPE_INNER"+ }+ },+ "right": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "L_ORDERKEY",+ "L_PARTKEY",+ "L_SUPPKEY",+ "L_LINENUMBER",+ "L_QUANTITY",+ "L_EXTENDEDPRICE",+ "L_DISCOUNT",+ "L_TAX",+ "L_RETURNFLAG",+ "L_LINESTATUS",+ "L_SHIPDATE",+ "L_COMMITDATE",+ "L_RECEIPTDATE",+ "L_SHIPINSTRUCT",+ "L_SHIPMODE",+ "L_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "i32": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 1,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "fixedChar": {+ "length": 10,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 44,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_2",+ "parquet": {}+ }+ ]+ }+ }+ },+ "expression": {+ "literal": {+ "boolean": true,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "type": "JOIN_TYPE_INNER"+ }+ },+ "right": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "S_SUPPKEY",+ "S_NAME",+ "S_ADDRESS",+ "S_NATIONKEY",+ "S_PHONE",+ "S_ACCTBAL",+ "S_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 40,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 15,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 101,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "local_files": {+ "items": [+ {+ "uri_file": "file://FILENAME_PLACEHOLDER_3",+ "parquet": {}+ }+ ]+ }+ }+ },+ "expression": {+ "literal": {+ "boolean": true,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "type": "JOIN_TYPE_INNER"+ }+ },+ "right": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "N_NATIONKEY",+ "N_NAME",+ "N_REGIONKEY",+ "N_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "varchar": {+ "length": 152,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "namedTable": {+ "names": [+ "NATION"+ ]+ }+ }+ },+ "expression": {+ "literal": {+ "boolean": true,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "type": "JOIN_TYPE_INNER"+ }+ },+ "right": {+ "read": {+ "common": {+ "direct": {}+ },+ "baseSchema": {+ "names": [+ "R_REGIONKEY",+ "R_NAME",+ "R_COMMENT"+ ],+ "struct": {+ "types": [+ {+ "i64": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ {+ "varchar": {+ "length": 152,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ }+ ],+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "namedTable": {+ "names": [+ "REGION"+ ]+ }+ }+ },+ "expression": {+ "literal": {+ "boolean": true,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "type": "JOIN_TYPE_INNER"+ }+ },+ "condition": {+ "scalarFunction": {+ "functionReference": 0,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 9+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 17+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 8+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 19+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 33+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 3+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 36+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 36+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 40+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 42+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 44+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 1,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 45+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "cast": {+ "type": {+ "fixedChar": {+ "length": 25,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "input": {+ "literal": {+ "fixedChar": "ASIA",+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 2,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 12+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "cast": {+ "type": {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "input": {+ "literal": {+ "fixedChar": "1994-01-01",+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ }+ ]+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 3,+ "args": [],+ "outputType": {+ "bool": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 12+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "cast": {+ "type": {+ "date": {+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_REQUIRED"+ }+ },+ "input": {+ "literal": {+ "fixedChar": "1995-01-01",+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ }+ ]+ }+ }+ }+ ]+ }+ }+ }+ },+ "expressions": [+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 41+ }+ },+ "rootReference": {}+ }+ },+ {+ "scalarFunction": {+ "functionReference": 4,+ "args": [],+ "outputType": {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 22+ }+ },+ "rootReference": {}+ }+ }+ },+ {+ "value": {+ "scalarFunction": {+ "functionReference": 5,+ "args": [],+ "outputType": {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "arguments": [+ {+ "value": {+ "cast": {+ "type": {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "input": {+ "literal": {+ "i32": 1,+ "nullable": false,+ "typeVariationReference": 0+ }+ },+ "failureBehavior": "FAILURE_BEHAVIOR_UNSPECIFIED"+ }+ }+ },+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 23+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ }+ ]+ }+ }+ ]+ }+ },+ "groupings": [+ {+ "groupingExpressions": [+ {+ "selection": {+ "directReference": {+ "structField": {+ "field": 0+ }+ },+ "rootReference": {}+ }+ }+ ]+ }+ ],+ "measures": [+ {+ "measure": {+ "functionReference": 6,+ "args": [],+ "sorts": [],+ "phase": "AGGREGATION_PHASE_INITIAL_TO_RESULT",+ "outputType": {+ "decimal": {+ "scale": 0,+ "precision": 19,+ "typeVariationReference": 0,+ "nullability": "NULLABILITY_NULLABLE"+ }+ },+ "invocation": "AGGREGATION_INVOCATION_ALL",+ "arguments": [+ {+ "value": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 1+ }+ },+ "rootReference": {}+ }+ }+ }+ ]+ }+ }+ ]+ }+ },+ "sorts": [+ {+ "expr": {+ "selection": {+ "directReference": {+ "structField": {+ "field": 1+ }+ },+ "rootReference": {}+ }+ },+ "direction": "SORT_DIRECTION_DESC_NULLS_FIRST"+ }+ ]+ }+ },+ "names": [+ "N_NAME",+ "REVENUE"+ ]+ }+ }+ ],+ "expectedTypeUrls": []+}\ No newline at end of file