Add something like this to SqlLibraryOperators:

  @LibraryOperator(libraries = {POSTGRESQL})
  public static final SqlFunction LENGTH = ...;

and create your JDBC connection with 'fun=postgresql'.

LENGTH is not part of the SQL standard, so it should not be in
SqlStdOperatorTable.

Nor should you add SQL standard operators to SqlLibraryOperators; they
belong in SqlStdOperatorTable.

There is not a library for Presto but we could consider adding one.
It's probably only worthwhile if it is significantly different from
other DBs.

Julian

On Wed, Jul 8, 2020 at 11:50 AM James Anderson <ja...@finitestate.io> wrote:
>
> Hi,
>
> Is there a mechanism to add/register additional standard operators to be
> used by Calcite when defining a model for a JDBC connection?  I had hoped
> that annotating new functions with LibraryOperator(libraries={STANDARD})
> would work but it doesn't seem to be the case, or I'm doing it incorrectly.
>
> My use case is that I'd like to port a query between two different backends
> (Presto, Postgres) that both offer a built-in operator (LENGTH, for
> example), which isn't part of SqlStdOperatorTable but I'd like to be able
> to support validating queries that call that function without creating my
> own FrameworkConfig, Planner, etc.
>
> Thanks!
> James

Reply via email to