-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include input fields as output for Substrait consumer #12225
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//! Tests for bugs in substrait | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use datafusion::arrow::datatypes::{DataType, Field, Schema}; | ||
use datafusion::common::Result; | ||
use datafusion::datasource::MemTable; | ||
use datafusion::prelude::SessionContext; | ||
use datafusion_substrait::logical_plan::consumer::from_substrait_plan; | ||
use std::fs::File; | ||
use std::io::BufReader; | ||
use std::sync::Arc; | ||
use substrait::proto::Plan; | ||
#[tokio::test] | ||
async fn extra_projection_with_input() -> Result<()> { | ||
let ctx = SessionContext::new(); | ||
let schema = Schema::new(vec![ | ||
Field::new("user_id", DataType::Utf8, false), | ||
Field::new("name", DataType::Utf8, false), | ||
Field::new("paid_for_service", DataType::Boolean, false), | ||
]); | ||
let memory_table = MemTable::try_new(schema.into(), vec![vec![]]).unwrap(); | ||
ctx.register_table("users", Arc::new(memory_table))?; | ||
let path = "tests/testdata/extra_projection_with_input.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: users.user_id, users.name, users.paid_for_service, row_number() ORDER BY [users.name ASC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS row_number\ | ||
\n WindowAggr: windowExpr=[[row_number() ORDER BY [users.name ASC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]]\ | ||
\n TableScan: users projection=[user_id, name, paid_for_service]"); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
datafusion/substrait/tests/testdata/extra_projection_with_input.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"extensionUris": [ | ||
{ | ||
"extensionUriAnchor": 1, | ||
"uri": "/functions_arithmetic.yaml" | ||
} | ||
], | ||
"extensions": [ | ||
{ | ||
"extensionFunction": { | ||
"extensionUriReference": 1, | ||
"functionAnchor": 1, | ||
"name": "row_number" | ||
} | ||
} | ||
], | ||
"relations": [ | ||
{ | ||
"root": { | ||
"input": { | ||
"project": { | ||
"common": { | ||
"direct": {} | ||
}, | ||
"input": { | ||
"read": { | ||
"common": { | ||
"direct": {} | ||
}, | ||
"baseSchema": { | ||
"names": [ | ||
"user_id", | ||
"name", | ||
"paid_for_service" | ||
], | ||
"struct": { | ||
"types": [ | ||
{ | ||
"string": { | ||
"nullability": "NULLABILITY_REQUIRED" | ||
} | ||
}, | ||
{ | ||
"string": { | ||
"nullability": "NULLABILITY_REQUIRED" | ||
} | ||
}, | ||
{ | ||
"bool": { | ||
"nullability": "NULLABILITY_REQUIRED" | ||
} | ||
} | ||
], | ||
"nullability": "NULLABILITY_REQUIRED" | ||
} | ||
}, | ||
"namedTable": { | ||
"names": [ | ||
"users" | ||
] | ||
} | ||
} | ||
}, | ||
"expressions": [ | ||
{ | ||
"windowFunction": { | ||
"functionReference": 1, | ||
"sorts": [ | ||
{ | ||
"expr": { | ||
"selection": { | ||
"directReference": { | ||
"structField": { | ||
"field": 1 | ||
} | ||
}, | ||
"rootReference": {} | ||
} | ||
}, | ||
"direction": "SORT_DIRECTION_ASC_NULLS_FIRST" | ||
} | ||
], | ||
"upperBound": { | ||
"unbounded": {} | ||
}, | ||
"lowerBound": { | ||
"unbounded": {} | ||
}, | ||
"outputType": { | ||
"i64": { | ||
"nullability": "NULLABILITY_REQUIRED" | ||
} | ||
}, | ||
"invocation": "AGGREGATION_INVOCATION_ALL" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"names": [ | ||
"user_id", | ||
"name", | ||
"paid_for_service", | ||
"row_number" | ||
] | ||
} | ||
} | ||
], | ||
"version": { | ||
"minorNumber": 52, | ||
"producer": "spark-substrait-gateway" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like the right thing - but then to get tests passing again I think we'll also need to add support for the
remap
https://substrait.io/relations/basics/#emit-output-ordering, both here and in producer...