Hi all,

I am pretty aware that this question may have been asked before as I have
found references on stackoverflow but have yet to stumble on a response
which lays out the path on solving this.

Here is the problem I am facing -
I am using relational algebra to generate SQL on a table test_table with
two columns a and b fed into the calcite Framework (see below) via a custom
catalog. Both a and b are varchar columns.

FrameworkConfig config = Frameworks.newConfigBuilder().
                parserConfig(SqlParser.Config.DEFAULT).
                defaultSchema(addSchemas(rootSchema, schemaName, schema)).
<--- this is where I plug my custom table.
                traitDefs((List<RelTraitDef>) null).
                operatorTable(sqlOperatorTable).
                programs(Programs.heuristicJoinOrder(Programs.RULE_SET,
true, 2)).build()

The relational algebra is then used to generate SQL to the AnsiSqlDialect
and the resultant output SQL is

SELECT "a"
FROM test_table
WHERE "b" = 'value';

I have the SqlWriterConfig setup as such

SqlWriterConfig config = SqlPrettyWriter.config().
                withCaseClausesOnNewLines(false).
                withQuoteAllIdentifiers(false);

I have been trying to figure what needs to change in the sql writer but
after scanning stackoverflow it appears this is controlled by
CalciteConnectionConfig and potentially not the SqlWriter. Is this
accurate? and if so how do I assemble the right connection config when I am
building the custom catalog?

P.s: I am not parsing SQL but writing directly to the relational algebra
nodes so SqlParser does not come into play here.

Any pointers on how I can go about this is appreciated, say existing tests
or code which will help me put together a configuration which gets me to
this sql

SELECT a
FROM test_table
WHERE b = 'value';

Thanks in advance.

--Sandeep

Reply via email to