mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-29 14:27:36 +00:00
Support serdeproperties for CREATE TABLE with HIVE (#1152)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
68b52a4ad6
commit
fb7d4d40cc
4 changed files with 28 additions and 1 deletions
|
|
@ -3205,6 +3205,7 @@ impl fmt::Display for Statement {
|
|||
|
||||
if let Some(HiveFormat {
|
||||
row_format,
|
||||
serde_properties,
|
||||
storage,
|
||||
location,
|
||||
}) = hive_formats
|
||||
|
|
@ -3229,6 +3230,13 @@ impl fmt::Display for Statement {
|
|||
}
|
||||
_ => (),
|
||||
}
|
||||
if let Some(serde_properties) = serde_properties.as_ref() {
|
||||
write!(
|
||||
f,
|
||||
" WITH SERDEPROPERTIES ({})",
|
||||
display_comma_separated(serde_properties)
|
||||
)?;
|
||||
}
|
||||
if !*external {
|
||||
if let Some(loc) = location {
|
||||
write!(f, " LOCATION '{loc}'")?;
|
||||
|
|
@ -4886,6 +4894,7 @@ pub enum HiveIOFormat {
|
|||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct HiveFormat {
|
||||
pub row_format: Option<HiveRowFormat>,
|
||||
pub serde_properties: Option<Vec<SqlOption>>,
|
||||
pub storage: Option<HiveIOFormat>,
|
||||
pub location: Option<String>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ define_keywords!(
|
|||
SEQUENCEFILE,
|
||||
SEQUENCES,
|
||||
SERDE,
|
||||
SERDEPROPERTIES,
|
||||
SERIALIZABLE,
|
||||
SESSION,
|
||||
SESSION_USER,
|
||||
|
|
|
|||
|
|
@ -4353,7 +4353,12 @@ impl<'a> Parser<'a> {
|
|||
pub fn parse_hive_formats(&mut self) -> Result<HiveFormat, ParserError> {
|
||||
let mut hive_format = HiveFormat::default();
|
||||
loop {
|
||||
match self.parse_one_of_keywords(&[Keyword::ROW, Keyword::STORED, Keyword::LOCATION]) {
|
||||
match self.parse_one_of_keywords(&[
|
||||
Keyword::ROW,
|
||||
Keyword::STORED,
|
||||
Keyword::LOCATION,
|
||||
Keyword::WITH,
|
||||
]) {
|
||||
Some(Keyword::ROW) => {
|
||||
hive_format.row_format = Some(self.parse_row_format()?);
|
||||
}
|
||||
|
|
@ -4375,6 +4380,16 @@ impl<'a> Parser<'a> {
|
|||
Some(Keyword::LOCATION) => {
|
||||
hive_format.location = Some(self.parse_literal_string()?);
|
||||
}
|
||||
Some(Keyword::WITH) => {
|
||||
self.prev_token();
|
||||
let properties = self
|
||||
.parse_options_with_keywords(&[Keyword::WITH, Keyword::SERDEPROPERTIES])?;
|
||||
if !properties.is_empty() {
|
||||
hive_format.serde_properties = Some(properties);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None => break,
|
||||
_ => break,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue