I'm trying to put together a SQL generator, so I could dynamically build SQL statements, and pass them onto Spark Job Server. When the table columns are known in advance, it seems easy (using JOOQ):
String sql = DSL.select(field("field-1"), field("field-2"), field("field-3"))
.from(table("myTable"))
However, the goal here is to be able to parse an incoming HTTP POST, get the JSON schema out of it, and generate a SQL select statement based on the table structure described in the JSON.
...
List<String> fieldNames = new ArrayList<>();
fieldNames.add("field-1");
fieldNames.add("field-2");
fieldNames.add("field-3");
...
JOOQ "field" appears to be a strongly typed object.
Is there a way to build such JOOQ select statement, using such dynamically constructed list of columns?