Skip to content

Commit

Permalink
fix(sql): properly handle dashes in dataset names
Browse files Browse the repository at this point in the history
we have legacy users that include dashes, need to support sql'ing 'em.
  • Loading branch information
b5 committed Jul 2, 2020
1 parent 440a62d commit dbe472c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sql/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ func (p *processor) processTableRef(text string) error {

func toLegalName(refStr string) string {
refStr = strings.Replace(refStr, "@", "_at_", 1)
return strings.Replace(refStr, "/", "_", -1)
refStr = strings.ReplaceAll(refStr, "/", "_")
return strings.ReplaceAll(refStr, "-", "_")
}

// scan reads one token from the input stream
Expand Down
8 changes: 8 additions & 0 deletions sql/preprocess/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func TestPrepropcess(t *testing.T) {
},
},

{
"SELECT * FROM nyc-transit-data/turnstile_daily_counts_2019 t LIMIT 10",
"SELECT * FROM nyc_transit_data_turnstile_daily_counts_2019 t LIMIT 10",
map[string]string{
"nyc_transit_data_turnstile_daily_counts_2019": "nyc-transit-data/turnstile_daily_counts_2019",
},
},

{
"SELECT (SELECT 1)",
"SELECT (SELECT 1)",
Expand Down

0 comments on commit dbe472c

Please sign in to comment.