Skip to content

Commit 44afbb2

Browse files
committed
Deprecate and ignore enable_options_value_normalization
1 parent 947d1c2 commit 44afbb2

File tree

6 files changed

+11
-36
lines changed

6 files changed

+11
-36
lines changed

datafusion-cli/Cargo.lock

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

datafusion/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ half = { workspace = true }
5757
hashbrown = { workspace = true }
5858
indexmap = { workspace = true }
5959
libc = "0.2.140"
60+
log = { workspace = true }
6061
object_store = { workspace = true, optional = true }
6162
parquet = { workspace = true, optional = true, default-features = true }
6263
paste = "1.0.15"

datafusion/common/src/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ macro_rules! config_namespace {
113113
$vis:vis struct $struct_name:ident {
114114
$(
115115
$(#[doc = $d:tt])*
116-
$field_vis:vis $field_name:ident : $field_type:ty, $(transform = $transform:expr,)? default = $default:expr
116+
$field_vis:vis $field_name:ident : $field_type:ty, $(warn = $warn: expr,)? $(transform = $transform:expr,)? default = $default:expr
117117
)*$(,)*
118118
}
119119
) => {
@@ -135,6 +135,7 @@ macro_rules! config_namespace {
135135
$(
136136
stringify!($field_name) => {
137137
$(let value = $transform(value);)?
138+
$(log::warn!($warn);)?
138139
self.$field_name.set(rem, value.as_ref())
139140
},
140141
)*
@@ -219,7 +220,9 @@ config_namespace! {
219220
pub enable_ident_normalization: bool, default = true
220221

221222
/// When set to true, SQL parser will normalize options value (convert value to lowercase)
222-
pub enable_options_value_normalization: bool, default = false
223+
/// Note that this option is ignored and will be removed in the future. All case-insensitive values
224+
/// are normalized automatically.
225+
pub enable_options_value_normalization: bool, warn = "`enable_options_value_normalization` is deprecated and ignored", default = false
223226

224227
/// Configure the SQL dialect used by DataFusion's parser; supported values include: Generic,
225228
/// MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, MsSQL, ClickHouse, BigQuery, and Ansi.

datafusion/sql/src/planner.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ use arrow_schema::*;
2424
use datafusion_common::{
2525
field_not_found, internal_err, plan_datafusion_err, DFSchemaRef, SchemaError,
2626
};
27+
use sqlparser::ast::TimezoneInfo;
2728
use sqlparser::ast::{ArrayElemTypeDef, ExactNumberInfo};
2829
use sqlparser::ast::{ColumnDef as SQLColumnDef, ColumnOption};
2930
use sqlparser::ast::{DataType as SQLDataType, Ident, ObjectName, TableAlias};
30-
use sqlparser::ast::{TimezoneInfo, Value};
3131

3232
use datafusion_common::TableReference;
3333
use datafusion_common::{
@@ -38,7 +38,7 @@ use datafusion_expr::logical_plan::{LogicalPlan, LogicalPlanBuilder};
3838
use datafusion_expr::utils::find_column_exprs;
3939
use datafusion_expr::{col, Expr};
4040

41-
use crate::utils::{make_decimal_type, value_to_string};
41+
use crate::utils::make_decimal_type;
4242
pub use datafusion_expr::planner::ContextProvider;
4343

4444
/// SQL parser options
@@ -87,32 +87,6 @@ impl IdentNormalizer {
8787
}
8888
}
8989

90-
/// Value Normalizer
91-
#[derive(Debug)]
92-
pub struct ValueNormalizer {
93-
normalize: bool,
94-
}
95-
96-
impl Default for ValueNormalizer {
97-
fn default() -> Self {
98-
Self { normalize: true }
99-
}
100-
}
101-
102-
impl ValueNormalizer {
103-
pub fn new(normalize: bool) -> Self {
104-
Self { normalize }
105-
}
106-
107-
pub fn normalize(&self, value: Value) -> Option<String> {
108-
match (value_to_string(&value), self.normalize) {
109-
(Some(s), true) => Some(s.to_ascii_lowercase()),
110-
(Some(s), false) => Some(s),
111-
(None, _) => None,
112-
}
113-
}
114-
}
115-
11690
/// Struct to store the states used by the Planner. The Planner will leverage the states to resolve
11791
/// CTEs, Views, subqueries and PREPARE statements. The states include
11892
/// Common Table Expression (CTE) provided with WITH clause and
@@ -254,7 +228,6 @@ pub struct SqlToRel<'a, S: ContextProvider> {
254228
pub(crate) context_provider: &'a S,
255229
pub(crate) options: ParserOptions,
256230
pub(crate) ident_normalizer: IdentNormalizer,
257-
pub(crate) value_normalizer: ValueNormalizer,
258231
}
259232

260233
impl<'a, S: ContextProvider> SqlToRel<'a, S> {
@@ -266,13 +239,11 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
266239
/// Create a new query planner
267240
pub fn new_with_options(context_provider: &'a S, options: ParserOptions) -> Self {
268241
let ident_normalize = options.enable_ident_normalization;
269-
let options_value_normalize = options.enable_options_value_normalization;
270242

271243
SqlToRel {
272244
context_provider,
273245
options,
274246
ident_normalizer: IdentNormalizer::new(ident_normalize),
275-
value_normalizer: ValueNormalizer::new(options_value_normalize),
276247
}
277248
}
278249

datafusion/sql/src/statement.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
13861386
return plan_err!("Option {key} is specified multiple times");
13871387
}
13881388

1389-
let Some(value_string) = self.value_normalizer.normalize(value.clone())
1390-
else {
1389+
let Some(value_string) = crate::utils::value_to_string(&value) else {
13911390
return plan_err!("Unsupported Value {}", value);
13921391
};
13931392

datafusion/sqllogictest/test_files/information_schema.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ datafusion.optimizer.skip_failed_rules false When set to true, the logical plan
351351
datafusion.optimizer.top_down_join_key_reordering true When set to true, the physical plan optimizer will run a top down process to reorder the join keys
352352
datafusion.sql_parser.dialect generic Configure the SQL dialect used by DataFusion's parser; supported values include: Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, MsSQL, ClickHouse, BigQuery, and Ansi.
353353
datafusion.sql_parser.enable_ident_normalization true When set to true, SQL parser will normalize ident (convert ident to lowercase when not quoted)
354-
datafusion.sql_parser.enable_options_value_normalization false When set to true, SQL parser will normalize options value (convert value to lowercase)
354+
datafusion.sql_parser.enable_options_value_normalization false When set to true, SQL parser will normalize options value (convert value to lowercase) Note that this option is ignored and will be removed in the future. All case-insensitive values are normalized automatically.
355355
datafusion.sql_parser.parse_float_as_decimal false When set to true, SQL parser will parse float as decimal type
356356
datafusion.sql_parser.support_varchar_with_length true If true, permit lengths for `VARCHAR` such as `VARCHAR(20)`, but ignore the length. If false, error if a `VARCHAR` with a length is specified. The Arrow type system does not have a notion of maximum string length and thus DataFusion can not enforce such limits.
357357

0 commit comments

Comments
 (0)