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

Julian Hyde commented on CALCITE-4963:
--------------------------------------

(Thanks for the niceties!)

Let me push back on this, to see whether there's a simpler solution to your 
problem. The {{SqlDialectFactory}} interface has only one method, 
{{create(DatabaseMetaData)}}, so we figured that it would be fairly easy for 
people to create their own factories.

Now, is there some specific logic that is locked inside 
{{SqlDialectFactoryImpl}} that you need in your factory? For example, logic to 
go from a {{DatabaseMetaData}} to a {{SqlDialect.Context}}? If so, we could 
consider moving that logic into a {{public static}} method.

Did you consider using a chain-of-responsibility pattern? Your dialect factory 
would try to create a dialect, and if it cannot, it calls {{delegate.create}}, 
where {{delegate}} is a field that points to the next factory in the chain, 
probably {{SqlDialectFactoryImpl.INSTANCE}}.

As part of your PR, can you provide a test? For example, create a dialect 
factory that creates a different dialect object for MySQL version 3 and 
earlier, and delegates to the default factory for other databases or versions.

> Extensibility of SqlDialectFactory lacks reusability of 
> SqlDialectFactoryImpl.*
> -------------------------------------------------------------------------------
>
>                 Key: CALCITE-4963
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4963
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Marco Jorge
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> _(nicetities first - great project and thanks all for the great work)_
> Although it's possible to extend the SqlDialectFactory, the custom 
> implementation cannot reuse any of the behaviour of the default 
> SqlDialectFactoryImpl. The default SqlDialectFactoryImpl has lots of 
> important/reusable behaviour such as #getCasing, #isCaseSensitive, 
> #getNullCollation or even the default decisioning in the #create method.
> If any user needs to provide a custom SqlDialect yet still support the 
> existing SqlDialects the user needs to copy the whole SqlDialectFactoryImpl 
> to make the custom changes.
> This request is to make the default behavior in SqlDialectFactoryImpl 
> reusable so that extensions don't need to fork a whole class.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to