Skip to content

Commit 0d69155

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 5746048 commit 0d69155

48 files changed

Lines changed: 5128 additions & 1745 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 1809 additions & 1602 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
@@ -184,7 +184,9 @@ regex = "1.12"
184184
rstest = "0.26.1"
185185
serde_json = "1"
186186
sha2 = "^0.10.9"
187-
sqlparser = { version = "0.61.0", default-features = false, features = ["std", "visitor"] }
187+
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "46c81692142afa6812d3b3bbe49d3daeb361e895", features = [
188+
"visitor",
189+
] }
188190
strum = "0.28.0"
189191
strum_macros = "0.28.0"
190192
tempfile = "3"

FETCH_HEAD

Whitespace-only changes.

datafusion-cli/src/functions.rs

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

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

datafusion-examples/examples/dataframe/dataframe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ pub async fn dataframe_example() -> Result<()> {
6969
write_out(&ctx).await?;
7070
register_cars_test_data("t1", &ctx).await?;
7171
register_cars_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/udf/simple_udtf.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ impl TableProvider for LocalCsvTable {
135135
struct LocalCsvTableFunc {}
136136

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

143144
let limit = exprs
144145
.get(1)
145-
.map(|expr| {
146+
.map(|(expr, _)| {
146147
// try to simplify the expression, so 1+2 becomes 3, for example
147148
let info = SimplifyContext::default();
148149
let expr = ExprSimplifier::new(info).simplify(expr.clone())?;

datafusion/catalog/src/table.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub trait TableProviderFactory: Debug + Sync + Send {
488488
/// A trait for table function implementations
489489
pub trait TableFunctionImpl: Debug + Sync + Send {
490490
/// Create a table provider
491-
fn call(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>>;
491+
fn call(&self, args: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>>;
492492
}
493493

494494
/// A table that uses a function to generate data
@@ -517,7 +517,10 @@ impl TableFunction {
517517
}
518518

519519
/// Get the function implementation and generate a table
520-
pub fn create_table_provider(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>> {
520+
pub fn create_table_provider(
521+
&self,
522+
args: &[(Expr, Option<String>)],
523+
) -> Result<Arc<dyn TableProvider>> {
521524
self.fun.call(args)
522525
}
523526
}

datafusion/core/src/execution/session_state.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl Session for SessionState {
292292
}
293293

294294
impl SessionState {
295-
pub(crate) fn resolve_table_ref(
295+
pub fn resolve_table_ref(
296296
&self,
297297
table_ref: impl Into<TableReference>,
298298
) -> ResolvedTableReference {
@@ -515,7 +515,8 @@ impl SessionState {
515515
}
516516

517517
#[cfg(feature = "sql")]
518-
fn get_parser_options(&self) -> ParserOptions {
518+
/// Get the parser options
519+
pub fn get_parser_options(&self) -> ParserOptions {
519520
let sql_parser_options = &self.config.options().sql_parser;
520521

521522
ParserOptions {
@@ -1790,9 +1791,11 @@ impl From<SessionState> for SessionStateBuilder {
17901791
/// This is used so the SQL planner can access the state of the session without
17911792
/// having a direct dependency on the [`SessionState`] struct (and core crate)
17921793
#[cfg(feature = "sql")]
1793-
struct SessionContextProvider<'a> {
1794-
state: &'a SessionState,
1795-
tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>,
1794+
pub struct SessionContextProvider<'a> {
1795+
/// The session state
1796+
pub state: &'a SessionState,
1797+
/// The tables available in the session
1798+
pub tables: HashMap<ResolvedTableReference, Arc<dyn TableSource>>,
17961799
}
17971800

17981801
#[cfg(feature = "sql")]
@@ -1827,12 +1830,13 @@ impl ContextProvider for SessionContextProvider<'_> {
18271830
fn get_table_function_source(
18281831
&self,
18291832
name: &str,
1830-
args: Vec<Expr>,
1833+
args: Vec<(Expr, Option<String>)>,
18311834
) -> datafusion_common::Result<Arc<dyn TableSource>> {
1835+
let name = name.to_ascii_lowercase();
18321836
let tbl_func = self
18331837
.state
18341838
.table_functions
1835-
.get(name)
1839+
.get(&name)
18361840
.cloned()
18371841
.ok_or_else(|| plan_datafusion_err!("table function '{name}' not found"))?;
18381842
let simplify_context = SimplifyContext::default()
@@ -1844,10 +1848,11 @@ impl ContextProvider for SessionContextProvider<'_> {
18441848
let schema = DFSchema::empty();
18451849
let args = args
18461850
.into_iter()
1847-
.map(|arg| {
1851+
.map(|(expr, named_param)| {
18481852
simplifier
1849-
.coerce(arg, &schema)
1853+
.coerce(expr, &schema)
18501854
.and_then(|e| simplifier.simplify(e))
1855+
.map(|e| (e, named_param))
18511856
})
18521857
.collect::<datafusion_common::Result<Vec<_>>>()?;
18531858
let provider = tbl_func.create_table_provider(&args)?;

0 commit comments

Comments
 (0)