[ 
https://issues.apache.org/jira/browse/CALCITE-6029?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17769858#comment-17769858
 ] 

Mihai Budiu commented on CALCITE-6029:
--------------------------------------

I want to write a test for an operator which can only be parsed with the Babel 
parser.
I don't want a parser test, I want an operator test.
In particular, I was trying to test the DATE_PART function. Loading the 
Postgres library is not enough, you also need the Babel parser for that. But I 
have discovered in this process 2 bugs, this one and [CALCITE-6030], which I 
have fixed separately.

But leaving this aside, I think that it's a bug that you can specify the 
parserConfig in the test fixture and the parserConfig is ignored by the test 
connection created by the tester. See the PR attached, which fixes this bug. 
With this change one should be able to test any operator using the 
SqlOperatorTest and its fixtures.

> SqlOperatorTest cannot test operators that require the Babel parser
> -------------------------------------------------------------------
>
>                 Key: CALCITE-6029
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6029
>             Project: Calcite
>          Issue Type: Bug
>          Components: babel, core
>    Affects Versions: 1.35.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>
> In SqlOperatorTest one can write code like this:
> {code:java}
> @Test void testDatePart() {
>     final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.POSTGRESQL)
>         .withParserConfig(p -> 
> p.withParserFactory(SqlBabelParserImpl.FACTORY));
> {code}
> This almost works, but the SqlOperatorTest.check function makes a connection 
> ignores the parserFactory, so parsing will fail:
> {code:java}
>     @Override public void check(SqlTestFactory factory, String query,
>         SqlTester.TypeChecker typeChecker,
>         SqlTester.ParameterChecker parameterChecker,
>         SqlTester.ResultChecker resultChecker) {
>       super.check(factory, query, typeChecker, parameterChecker, 
> resultChecker);
>       final RelDataTypeSystem typeSystem =
>           factory.typeSystemTransform.apply(RelDataTypeSystem.DEFAULT);
>       final ConnectionFactory connectionFactory =
>           factory.connectionFactory
>               .with(CalciteConnectionProperty.TYPE_SYSTEM, uri(FIELD));  /// 
> NO PARSER_FACTORY HERE
> {code}
> I am trying to fix this by adding a PARSER_FACTORY argument to the 
> connection, but then I get a class loader error from 
> AvaticaUtils.instantiatePlugin, which, in this case, cannot find the 
> SqlBabelParserImpl#FACTORY in the classpath.
> I would appreciate some help solving this last bit.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to