sql-machine-learning / gomaxcompute

A Go driver for MaxCompute.
41 stars 11 forks source link

Handle missing semicolon #25

Closed tonyyang-svail closed 5 years ago

tonyyang-svail commented 5 years ago

If a user forgot ";" at the end of a SQL statement. The current implementation will return parseResponseBody error: 400, which is not informative.

We should either

  1. Print more informative error messages
  2. Autocomplete the ";"

Code to reproduce:

package main

import (
    "fmt"
    "os"
    "sqlflow.org/gomaxcompute"
    "database/sql"
)

func main() {
    config := gomaxcompute.Config{...}

    db, _ := sql.Open("maxcompute", config.FormatDSN())
    assertNoErr(err)

    // Will raise "parseResponseBody error: 400"
    rows, err := db.Query("SELECT * FROM yiyang_test_table1") // forgot to add ";" in the end
    fmt.Println(err)
}