I am getting the following exception when trying to fetch a text column from a table in PostgreSQL. How to resolve it. Table schema :
Snapshot of data :
Table resultTable = tenv.sqlQuery(
"SELECT entity_id, CONVERT_FROM(LO_GET(event_payload::oid), 'UTF8') " +
"FROM event_log");
Exception stack trace
Caused by: org.apache.flink.sql.parser.impl.ParseException: Encountered ":" at line 1, column 52.
Was expecting one of:
"EXCEPT" ...
Dependencies
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>1.17.2</version>
</dependency>
<!-- Required for connecting to JDBC -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc</artifactId>
<version>1.16.2</version>
</dependency>
UPDATE :
I tried changing the query but getting new exception
Table resultTable = tenv.sqlQuery(
"SELECT entity_id, convert_from(lo_get(cast (event_payload as OID )), 'UTF8') " +
"FROM event_log");
Exception
org.apache.flink.table.api.ValidationException: SQL validation failed. From line 1, column 62 to line 1, column 64: Unknown identifier 'OID'
at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:187)
as OID
it should be after function call likeSELECT your_function(event_payload ) AS oid FROM ...