user7432713
user7432713

Reputation: 226

Parse error while selecting Double column in Apache Flink SQL

I've imported data from a CSV file into Apache Flink Java using the TableSource class and registered the table as u can see in the big code sample entirely below. When I print the datatype of the HBATable I get the following output:

|-- measurementID: INT
|-- dateTime: TIMESTAMP(3)
|-- result: DOUBLE
|-- unixDateTime: BIGINT

The problem is when I try to perform a simple SQL query on the HBATable I get a parseError on the Result column. U can see the simple SQL query below and the error message.

Table t = tableEnv.sqlQuery("SELECT result FROM HBATable " );

Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed. Encountered "result" at line 1, column 8

        BatchTableEnvironment tableEnv = BatchTableEnvironment.create(fbEnv);

        TableSource csvSource = CsvTableSource.builder()
                .path("path")
                .fieldDelimiter(";")
                .field("ID", Types.INT())
                .field("dateTime", Types.SQL_TIMESTAMP())
                .field("result", Types.DOUBLE())
                .field("unixDateTime", Types.LONG())
                .build();

        //Register the TableSource as table "HTable"
        tableEnv.registerTableSource("HTable", csvSource);
        Table HBATable = tableEnv.scan("HTable");
        tableEnv.registerTable("HBATable", HBATable);

Upvotes: 1

Views: 984

Answers (1)

David Anderson
David Anderson

Reputation: 43454

result is a reserved keyword. Try renaming that field.

Upvotes: 4

Related Questions