Skip to content

Commit

Permalink
Merge #28568
Browse files Browse the repository at this point in the history
28568: sql/sem/tree: fix the pretty-printing for IMPORT r=knz a=knz

Fixes #28562.

The IMPORT statement didn't roundtrip properly. This patch fixes it.

Also the contextual help is extended to include the new IMPORT syntax.

Release note: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Aug 14, 2018
2 parents 738050b + e2ea44e commit 7462423
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ func TestParse(t *testing.T) {
{`IMPORT TABLE foo CREATE USING 'nodelocal:///some/file' MYSQLOUTFILE DATA ('path/to/some/file', $1)`},
{`IMPORT TABLE foo (id INT PRIMARY KEY, email STRING, age INT) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`},
{`IMPORT TABLE foo (id INT, email STRING, age INT) CSV DATA ('path/to/some/file', $1) WITH comma = ',', "nullif" = 'n/a', temp = $2`},
{`IMPORT TABLE foo FROM PGDUMPCREATE ('nodelocal:///some/file') WITH temp = 'path/to/temp'`},
{`EXPORT INTO CSV 'a' FROM TABLE a`},
{`EXPORT INTO CSV 'a' FROM SELECT * FROM a`},
{`EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a`},
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,10 @@ import_format:
// %Help: IMPORT - load data from file in a distributed manner
// %Category: CCL
// %Text:
// IMPORT [ TABLE <tablename> FROM ]
// <format> ( <datafile> )
// [ WITH <option> [= <value>] [, ...] ]
//
// IMPORT TABLE <tablename>
// { ( <elements> ) | CREATE USING <schemafile> }
// <format>
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/sem/tree/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (node *Import) Format(ctx *FmtCtx) {

if node.Bundle {
if node.Table.TableNameReference != nil {
ctx.WriteString("TABLE ")
ctx.FormatNode(&node.Table)
ctx.WriteString(" FROM ")
}
Expand Down

0 comments on commit 7462423

Please sign in to comment.