Skip to content

Commit e34218c

Browse files
osipovartemJanKaul
authored andcommitted
Changes from Embucket on top of 47.0.0
Make required funcs public (#1) * Make required funcs public * Make required funcs public * Make required funcs public Extend to_date UDF supported types (#3) * Extend to_date supported types * Remove TODO Add "rlike" as an alias for regexp_like (#2) * Add "rlike" as an alias for regexp_like * Update docs Extend references with new ShowSchemas type (#4) * Extend references with new SHowSchemas type * Make resolve_table_ref as pub * Fix docs linter Implement regexp_substr (#6) * Extend references with new SHowSchemas type Make resolve_table_ref as pub Fix docs linter Add DDL AlterTable Add DDL AlterTable Add "rlike" as an alias for regexp_like (#2) * Add "rlike" as an alias for regexp_like * Update docs Extend references with new ShowSchemas type (#4) * Extend references with new SHowSchemas type * Make resolve_table_ref as pub * Fix docs linter Fix deps Import alter table Temp Temp Add regexp_substr udf Add regexp_substr udf Add regexp_substr udf Add regexp_substr udf * Add regexp_substr to docs * Update comments and fix returned datatype * Update docs Make statements publci (#7) Make context public (#9) * Make conext public * Fix clippy DFParser should skip unsupported COPY INTO (#10) Skip CREATE STAGE by DFParser (pass to dialect parser) (#11) * DFParser should skip unsupported COPY INTO * Add tests * Add tests * Add tests * Add tests * Fmt * Fmt * Fmt Extend references with new Show* types (#14) Add e flag support (#16) * Add e flag support * Add e flag support * fix fmt * clippy return Int64 instead of UInt64 when returning count (#17) Revert commit: 314a726 (#18) * Revert "return Int64 instead of UInt64 when returning count (#17)" This reverts commit 314a726. * revert changes as of a bad approach use Bump sqlparser version to 0.55. Fixes after rebase named arguments for table functions (#20) TableFunction Fixes (#23) * TableFunction Fixes * Also fix tests after rebase * Taplo format * Clippy * Fix docs PIVOT command (#22) * Pivot initial changes * Polishing * Rebase fixes * Add slt tests * Add display for PIVOT * Only check projections in case of subqueries * Add builder test * Add default on null. Cargo fmt * Add default_on_null to proto and tests * Fix protoc and clippy * Cargo fmt Update parser version (#26) Fix incompatible type in IS NOT DISTINCT filter for PIVOT (#25) * Fix incompattible type in IS NOT DISTINCT filter * Cargo fmt * Cargo clippy UNPIVOT command (#24) * UNPIVOT command implementation * UNPIVOT command * Add slt tests * Taplo and cargo fmt * Resolve comments Update sql-parser Update parser update parser with fetch (#28) Enhance string concat coercion to support castable types (#27) * Allow any stringle types for concatination * Fix fmt Added basic support for table functions in relations (#29) * Add basic support for flatten join * Fix outer Update sqlparser-version Get table function in ascii lowercase (#30) * Get table function in ascii lowercase * Get table function in ascii lowercase Update parser version Update parser Allow boolean vs integer comparison (#31) * Allow comparison between boolean and int values * Allow comparison between boolean and int values * Add integer types * clippy+fmt+tests fix * tests fix * Fix incompatible types test * Fix slt test * Fix docs Fix unpivot. Columns result always in uppercase (#32) Update parser (#33) * Update parser * Update version * Update parser and external table * Fix external table * Fix external table `QUALIFY` clause implementation (#34) * Implement clause * Remove comment * Remove unimplemented Support projection in subquery with IN clause (#35) Update parser with SECURE keyword for views (#36) * Update parser with SECURE keyword for views * update rustc version for compatibility Decorellate subqueries in IN inside JOIN filter and Aggregates (#37)
1 parent 37455c7 commit e34218c

File tree

48 files changed

+3326
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3326
-151
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ recursive = "0.1.1"
173173
regex = "1.11"
174174
rstest = "0.25.0"
175175
serde_json = "1"
176-
sqlparser = { version = "0.58.0", default-features = false, features = ["std", "visitor"] }
176+
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "8d9cbc2669d7fc3d79d7d1d725ac20f1e9bfe10e", features = [
177+
"visitor",
178+
] }
177179
tempfile = "3"
178180
testcontainers = { version = "0.24", features = ["default"] }
179181
testcontainers-modules = { version = "0.12" }

FETCH_HEAD

Whitespace-only changes.

datafusion-cli/src/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ fn fixed_len_byte_array_to_string(val: Option<&FixedLenByteArray>) -> Option<Str
321321
pub struct ParquetMetadataFunc {}
322322

323323
impl TableFunctionImpl for ParquetMetadataFunc {
324-
fn call(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
324+
fn call(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
325325
let filename = match exprs.first() {
326-
Some(Expr::Literal(ScalarValue::Utf8(Some(s)), _)) => s, // single quote: parquet_metadata('x.parquet')
326+
Some((Expr::Literal(ScalarValue::Utf8(Some(s)), _), _)) => s, // single quote: parquet_metadata('x.parquet')
327327
Some(Expr::Column(Column { name, .. })) => name, // double quote: parquet_metadata("x.parquet")
328328
_ => {
329329
return plan_err!(

datafusion-examples/examples/dataframe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ async fn main() -> Result<()> {
6969
write_out(&ctx).await?;
7070
register_aggregate_test_data("t1", &ctx).await?;
7171
register_aggregate_test_data("t2", &ctx).await?;
72-
where_scalar_subquery(&ctx).await?;
73-
where_in_subquery(&ctx).await?;
72+
Box::pin(where_scalar_subquery(&ctx)).await?;
73+
Box::pin(where_in_subquery(&ctx)).await?;
7474
where_exist_subquery(&ctx).await?;
7575
Ok(())
7676
}

datafusion-examples/examples/simple_udtf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ impl TableProvider for LocalCsvTable {
132132
struct LocalCsvTableFunc {}
133133

134134
impl TableFunctionImpl for LocalCsvTableFunc {
135-
fn call(&self, exprs: &[Expr]) -> Result<Arc<dyn TableProvider>> {
136-
let Some(Expr::Literal(ScalarValue::Utf8(Some(ref path)), _)) = exprs.first()
135+
fn call(&self, exprs: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
136+
let Some((Expr::Literal(ScalarValue::Utf8(Some(ref path)), _), _)) = exprs.first()
137137
else {
138138
return plan_err!("read_csv requires at least one string argument");
139139
};
140140

141141
let limit = exprs
142142
.get(1)
143-
.map(|expr| {
143+
.map(|(expr, _)| {
144144
// try to simplify the expression, so 1+2 becomes 3, for example
145145
let execution_props = ExecutionProps::new();
146146
let info = SimplifyContext::new(&execution_props);

datafusion/catalog/src/table.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub trait TableProviderFactory: Debug + Sync + Send {
316316
/// A trait for table function implementations
317317
pub trait TableFunctionImpl: Debug + Sync + Send {
318318
/// Create a table provider
319-
fn call(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>>;
319+
fn call(&self, args: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>>;
320320
}
321321

322322
/// A table that uses a function to generate data
@@ -345,7 +345,10 @@ impl TableFunction {
345345
}
346346

347347
/// Get the function implementation and generate a table
348-
pub fn create_table_provider(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>> {
348+
pub fn create_table_provider(
349+
&self,
350+
args: &[(Expr, Option<String>)],
351+
) -> Result<Arc<dyn TableProvider>> {
349352
self.fun.call(args)
350353
}
351354
}

datafusion/core/src/execution/session_state.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl Session for SessionState {
274274
}
275275

276276
impl SessionState {
277-
pub(crate) fn resolve_table_ref(
277+
pub fn resolve_table_ref(
278278
&self,
279279
table_ref: impl Into<TableReference>,
280280
) -> ResolvedTableReference {
@@ -474,7 +474,8 @@ impl SessionState {
474474
query.statement_to_plan(statement)
475475
}
476476

477-
fn get_parser_options(&self) -> ParserOptions {
477+
/// Get the parser options
478+
pub fn get_parser_options(&self) -> ParserOptions {
478479
let sql_parser_options = &self.config.options().sql_parser;
479480

480481
ParserOptions {
@@ -1634,9 +1635,11 @@ impl From<SessionState> for SessionStateBuilder {
16341635
///
16351636
/// This is used so the SQL planner can access the state of the session without
16361637
/// having a direct dependency on the [`SessionState`] struct (and core crate)
1637-
struct SessionContextProvider<'a> {
1638-
state: &'a SessionState,
1639-
tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>,
1638+
pub struct SessionContextProvider<'a> {
1639+
/// The session state
1640+
pub state: &'a SessionState,
1641+
/// The tables available in the session
1642+
pub tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>,
16401643
}
16411644

16421645
impl ContextProvider for SessionContextProvider<'_> {
@@ -1666,20 +1669,25 @@ impl ContextProvider for SessionContextProvider<'_> {
16661669
fn get_table_function_source(
16671670
&self,
16681671
name: &str,
1669-
args: Vec<Expr>,
1672+
args: Vec<(Expr, Option<String>)>,
16701673
) -> datafusion_common::Result<Arc<dyn TableSource>> {
1674+
let name = name.to_ascii_lowercase();
16711675
let tbl_func = self
16721676
.state
16731677
.table_functions
1674-
.get(name)
1678+
.get(&name)
16751679
.cloned()
16761680
.ok_or_else(|| plan_datafusion_err!("table function '{name}' not found"))?;
16771681
let dummy_schema = DFSchema::empty();
16781682
let simplifier =
16791683
ExprSimplifier::new(SessionSimplifyProvider::new(self.state, &dummy_schema));
1684+
16801685
let args = args
16811686
.into_iter()
1682-
.map(|arg| simplifier.simplify(arg))
1687+
.map(|(expr, named_param)| {
1688+
// simplify returns Result<Expr>, map it into Result<(Expr, Option<String>)>
1689+
simplifier.simplify(expr).map(|e| (e, named_param))
1690+
})
16831691
.collect::<datafusion_common::Result<Vec<_>>>()?;
16841692
let provider = tbl_func.create_table_provider(&args)?;
16851693

0 commit comments

Comments
 (0)