QuakeWang commented on code in PR #250:
URL: https://github.com/apache/paimon-rust/pull/250#discussion_r3090579171
##########
crates/integrations/datafusion/src/sql_handler.rs:
##########
@@ -324,20 +319,87 @@ impl PaimonSqlHandler {
/// Convert a sqlparser [`ColumnDef`] to a Paimon [`SchemaChange::AddColumn`].
fn column_def_to_add_column(col: &ColumnDef) -> DFResult<SchemaChange> {
- let arrow_type = sql_data_type_to_arrow(&col.data_type)?;
- let nullable = !col.options.iter().any(|opt| {
- matches!(
- opt.option,
- datafusion::sql::sqlparser::ast::ColumnOption::NotNull
- )
- });
- let paimon_type = arrow_to_paimon_type(&arrow_type,
nullable).map_err(to_datafusion_error)?;
+ let paimon_type = column_def_to_paimon_type(col)?;
Ok(SchemaChange::add_column(
col.name.value.clone(),
paimon_type,
))
}
+fn column_def_to_paimon_type(col: &ColumnDef) -> DFResult<PaimonDataType> {
+ sql_data_type_to_paimon_type(&col.data_type, column_def_nullable(col))
+}
+
+fn column_def_nullable(col: &ColumnDef) -> bool {
+ !col.options.iter().any(|opt| {
+ matches!(
+ opt.option,
+ datafusion::sql::sqlparser::ast::ColumnOption::NotNull
+ )
+ })
+}
+
+/// Convert a sqlparser SQL data type to a Paimon data type.
+///
+/// DDL schema translation must use this function instead of going through
Arrow,
+/// because Arrow cannot preserve logical distinctions such as `BLOB` vs
`VARBINARY`.
+fn sql_data_type_to_paimon_type(
Review Comment:
@JingsongLi Thanks for the review. `sql_data_type_to_arrow` has been
removed, and DDL type translation now goes directly through
`sql_data_type_to_paimon_type`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]