Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable parser to parse create external clauses in arbitrary order #6257

Merged
merged 6 commits into from
May 8, 2023

Conversation

aprimadi
Copy link
Contributor

@aprimadi aprimadi commented May 6, 2023

Which issue does this PR close?

Closes #6248

Rationale for this change

N/A

What changes are included in this PR?

  • Modify create external table parser
  • Add some tests

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions bot added core Core DataFusion crate sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels May 6, 2023
@aprimadi aprimadi marked this pull request as ready for review May 6, 2023 07:45
ensure_not_set(&builder.options, "OPTIONS")?;
builder.options = Some(self.parse_options()?);
} else {
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure will it be worth adding more checks like expect_one_of_keywords (or other smarter ways) to make the user experience better? (though I couldn't find it's universally applied to all parser paths)

e.g. a typo like

CREATE EXTERNAL TABLE t(c1 int)
STORED AS CSV
WITH HEAD ROW
LOCATION 'foo.csv';

will turn into error sql parser error: Missing LOCATION clause in CREATE EXTERNAL TABLE statement which is a bit confusing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this would make a better user experience and I think it would be a good follow on project. I will file the ticket

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great -- thank you @aprimadi and @tz70s -- I will file a follow on ticket for the suggestion by @tz70s

} else {
vec![]
};
#[derive(Default)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

###############

# Missing `STORED AS` and `LOCATION` clauses
statement error DataFusion error: SQL error: ParserError\("Missing STORED AS clause in CREATE EXTERNAL TABLE statement"\)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 these tests are so nice -- thank you @aprimadi

ensure_not_set(&builder.options, "OPTIONS")?;
builder.options = Some(self.parse_options()?);
} else {
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this would make a better user experience and I think it would be a good follow on project. I will file the ticket

@alamb alamb changed the title Enable parser to parse create external clauses in random order Enable parser to parse create external clauses in arbitrary order May 8, 2023
@alamb alamb merged commit d94378e into apache:main May 8, 2023
@alamb
Copy link
Contributor

alamb commented May 8, 2023

Thanks @aprimadi

@aprimadi aprimadi deleted the ap-create-external branch May 9, 2023 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make CREATE EXTERNAL TABLE more user friendly
3 participants