Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3204,7 +3204,7 @@ impl fmt::Display for CreateTable {
} => {
write!(
f,
" SKEWED BY ({})) ON ({})",
" SKEWED BY ({}) ON ({})",
display_comma_separated(columns),
display_comma_separated(on)
)?;
Expand Down
31 changes: 27 additions & 4 deletions tests/sqlparser_hive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
//! Test SQL syntax specific to Hive. The parser based on the generic dialect
//! is also tested (on the inputs it can handle).

use sqlparser::ast::helpers::stmt_create_table::CreateTableBuilder;
use sqlparser::ast::{
ClusteredBy, CommentDef, CreateFunction, CreateFunctionBody, CreateFunctionUsing, CreateTable,
Expr, Function, FunctionArgumentList, FunctionArguments, Ident, ObjectName, OrderByExpr,
OrderByOptions, OrderBySort, SelectItem, Set, Statement, TableFactor, UnaryOperator, Use,
Value,
ClusteredBy, ColumnDef, CommentDef, CreateFunction, CreateFunctionBody, CreateFunctionUsing,
CreateTable, DataType, Expr, Function, FunctionArgumentList, FunctionArguments,
HiveDistributionStyle, Ident, ObjectName, OrderByExpr, OrderByOptions, OrderBySort, SelectItem,
Set, Statement, TableFactor, UnaryOperator, Use, Value,
};
use sqlparser::dialect::{AnsiDialect, GenericDialect, HiveDialect};
use sqlparser::parser::ParserError;
Expand Down Expand Up @@ -226,6 +227,28 @@ fn create_table_with_clustered_by() {
);
}

#[test]
fn display_create_table_with_skewed_by() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn display_create_table_with_skewed_by() {
fn create_table_with_skewed_by() {

let column = |name| ColumnDef {
name: Ident::new(name),
data_type: DataType::String(None),
options: vec![],
};
let stmt = CreateTableBuilder::new(ObjectName::from(vec![Ident::new("test")]))
.columns(vec![column("id")])
.hive_distribution(HiveDistributionStyle::SKEWED {
columns: vec![column("id")],
on: vec![column("id")],
stored_as_directories: true,
})
.build();

assert_eq!(
stmt.to_string(),
"CREATE TABLE test (id STRING) SKEWED BY (id STRING) ON (id STRING) STORED AS DIRECTORIES"
);
Comment on lines +231 to +249

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

}

// Turning off this test until we can parse identifiers starting with numbers :(
#[test]
fn test_identifier() {
Expand Down