parkma99 commented on code in PR #7160:
URL: https://github.com/apache/arrow-datafusion/pull/7160#discussion_r1281322058
##########
datafusion/sql/src/statement.rs:
##########
@@ -132,75 +132,93 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if_not_exists,
or_replace,
..
- } if table_properties.is_empty() && with_options.is_empty() =>
match query {
- Some(query) => {
- let plan = self.query_to_plan(*query, planner_context)?;
- let input_schema = plan.schema();
-
- let plan = if !columns.is_empty() {
- let schema =
self.build_schema(columns)?.to_dfschema_ref()?;
- if schema.fields().len() !=
input_schema.fields().len() {
- return Err(DataFusionError::Plan(format!(
+ } if table_properties.is_empty() && with_options.is_empty() => {
+ let mut constraints = constraints;
+ for column in &columns {
+ for option in &column.options {
+ if let ast::ColumnOption::Unique { is_primary } =
option.option {
+ constraints.push(ast::TableConstraint::Unique {
+ name: None,
+ columns: vec![column.name.clone()],
+ is_primary,
+ })
+ }
+ // TODO (parkma99) handle ForeignKey etc.
Review Comment:
I think it should not return `Error` because of without any constraints is
ok.
--
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]