make CommonFunctionFactory a real object

This commit is contained in:
Gavin King 2022-02-01 16:13:48 +01:00
parent fed23e51b5
commit d0255d2c2b
31 changed files with 1459 additions and 1483 deletions

View File

@ -184,58 +184,59 @@ public class CUBRIDDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.crc32( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.log2( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.trim2();
functionFactory.space();
functionFactory.reverse();
functionFactory.repeat();
functionFactory.crc32();
functionFactory.cot();
functionFactory.log2();
functionFactory.log10();
functionFactory.pi();
//rand() returns an integer between 0 and 231 on CUBRID
// CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.systimestamp( queryEngine );
// functionFactory.rand();
functionFactory.radians();
functionFactory.degrees();
functionFactory.systimestamp();
//TODO: CUBRID also has systime()/sysdate() returning TIME/DATE
CommonFunctionFactory.localtimeLocaltimestamp( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.md5( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.substr( queryEngine );
functionFactory.localtimeLocaltimestamp();
functionFactory.hourMinuteSecond();
functionFactory.yearMonthDay();
functionFactory.dayofweekmonthyear();
functionFactory.lastDay();
functionFactory.weekQuarter();
functionFactory.octetLength();
functionFactory.bitLength();
functionFactory.md5();
functionFactory.trunc();
functionFactory.truncate();
functionFactory.toCharNumberDateTimestamp();
functionFactory.substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.sha1( queryEngine );
CommonFunctionFactory.sha2( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.position( queryEngine );
// CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.insert( queryEngine );
CommonFunctionFactory.nowCurdateCurtime( queryEngine );
CommonFunctionFactory.makedateMaketime( queryEngine );
CommonFunctionFactory.bitandorxornot_bitAndOrXorNot( queryEngine );
CommonFunctionFactory.median( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.datediff( queryEngine );
CommonFunctionFactory.adddateSubdateAddtimeSubtime( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.rownumInstOrderbyGroupbyNum( queryEngine );
functionFactory.instr();
functionFactory.translate();
functionFactory.ceiling_ceil();
functionFactory.sha1();
functionFactory.sha2();
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.position();
// functionFactory.concat_pipeOperator();
functionFactory.insert();
functionFactory.nowCurdateCurtime();
functionFactory.makedateMaketime();
functionFactory.bitandorxornot_bitAndOrXorNot();
functionFactory.median();
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.variance();
functionFactory.varPopSamp();
functionFactory.datediff();
functionFactory.adddateSubdateAddtimeSubtime();
functionFactory.addMonths();
functionFactory.monthsBetween();
functionFactory.rownumInstOrderbyGroupbyNum();
}
@Override

View File

@ -138,34 +138,35 @@ public class CacheDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.repeat();
functionFactory.trim2();
functionFactory.substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.repeat_replicate( queryEngine );
CommonFunctionFactory.datepartDatename( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.nowCurdateCurtime( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
functionFactory.concat_pipeOperator();
functionFactory.cot();
functionFactory.log10();
functionFactory.log();
functionFactory.pi();
functionFactory.space();
functionFactory.hourMinuteSecond();
functionFactory.yearMonthDay();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.toCharNumberDateTimestamp();
functionFactory.truncate();
functionFactory.dayofweekmonthyear();
functionFactory.repeat_replicate();
functionFactory.datepartDatename();
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.nowCurdateCurtime();
functionFactory.sysdate();
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.variance();
functionFactory.varPopSamp();
functionFactory.lastDay();
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"locate",
@ -174,7 +175,7 @@ public class CacheDialect extends Dialect {
"$find(?2,?1,?3)",
STRING, STRING, INTEGER
).setArgumentListSignature("(pattern, string[, start])");
CommonFunctionFactory.bitLength_pattern( queryEngine, "($length(?1)*8)" );
functionFactory.bitLength_pattern( "($length(?1)*8)" );
useJdbcEscape(queryEngine, "sin");
useJdbcEscape(queryEngine, "cos");
@ -345,7 +346,7 @@ public class CacheDialect extends Dialect {
// callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
public int registerResultSetOutParameter(CallableStatement statement, int col) {
return col;
}

View File

@ -247,35 +247,36 @@ public class FirebirdDialect extends Dialect {
final BasicType<Double> doubleType = basicTypeRegistry.resolve( StandardBasicTypes.DOUBLE );
final BasicType<Character> characterType = basicTypeRegistry.resolve( StandardBasicTypes.CHARACTER );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.concat_pipeOperator();
functionFactory.cot();
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
if ( getVersion().isSameOrAfter( 3, 0 ) ) {
CommonFunctionFactory.moreHyperbolic( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.covarPopSamp( queryEngine );
CommonFunctionFactory.corr( queryEngine );
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
functionFactory.moreHyperbolic();
functionFactory.stddevPopSamp();
functionFactory.varPopSamp();
functionFactory.covarPopSamp();
functionFactory.corr();
functionFactory.regrLinearRegressionAggregates();
}
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.substringFromFor( queryEngine );
CommonFunctionFactory.overlay( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.bitandorxornot_binAndOrXorNot( queryEngine );
CommonFunctionFactory.leastGreatest_minMaxValue( queryEngine );
functionFactory.log();
functionFactory.log10();
functionFactory.pi();
functionFactory.rand();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.cosh();
functionFactory.trunc();
functionFactory.octetLength();
functionFactory.bitLength();
functionFactory.substringFromFor();
functionFactory.overlay();
functionFactory.position();
functionFactory.reverse();
functionFactory.bitandorxornot_binAndOrXorNot();
functionFactory.leastGreatest_minMaxValue();
SqmFunctionRegistry functionRegistry = queryEngine.getSqmFunctionRegistry();
functionRegistry.registerBinaryTernaryPattern(
@ -322,7 +323,7 @@ public class FirebirdDialect extends Dialect {
);
}
CommonFunctionFactory.listagg_list( "varchar", queryEngine );
functionFactory.listagg_list( "varchar" );
}
@Override

View File

@ -152,33 +152,34 @@ public class InformixDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.instr();
functionFactory.substr();
functionFactory.substring_substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.moreHyperbolic( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.locate_positionSubstring( queryEngine );
functionFactory.trunc();
functionFactory.trim2();
functionFactory.space();
functionFactory.reverse();
functionFactory.octetLength();
functionFactory.degrees();
functionFactory.radians();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.cosh();
functionFactory.moreHyperbolic();
functionFactory.log10();
functionFactory.initcap();
functionFactory.yearMonthDay();
functionFactory.ceiling_ceil();
functionFactory.concat_pipeOperator();
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.addMonths();
functionFactory.monthsBetween();
functionFactory.stddev();
functionFactory.variance();
functionFactory.locate_positionSubstring();
//coalesce() and nullif() both supported since Informix 12

View File

@ -253,32 +253,33 @@ public class IngresDialect extends Dialect {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Common functions
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.log();
functionFactory.rand();
functionFactory.soundex();
functionFactory.octetLength();
functionFactory.repeat();
functionFactory.trim2();
functionFactory.trunc();
functionFactory.truncate();
functionFactory.initcap();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.lastDay();
functionFactory.concat_pipeOperator();
functionFactory.substr();
functionFactory.monthsBetween();
functionFactory.substring_substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.format_dateFormat( queryEngine );
CommonFunctionFactory.dateTrunc( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "octet_length(hex(?1))*4" );
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.sysdate();
functionFactory.position();
functionFactory.format_dateFormat();
functionFactory.dateTrunc();
functionFactory.bitLength_pattern( "octet_length(hex(?1))*4" );
final BasicType<Integer> integerType = queryEngine.getTypeConfiguration().getBasicTypeRegistry()
.resolve( StandardBasicTypes.INTEGER );
@ -292,7 +293,7 @@ public class IngresDialect extends Dialect {
queryEngine.getSqmFunctionRegistry().registerPattern( "extract", "date_part('?1',?2)", integerType );
CommonFunctionFactory.bitandorxornot_bitAndOrXorNot(queryEngine);
functionFactory.bitandorxornot_bitAndOrXorNot();
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "squeeze" )
.setExactArgumentCount( 1 )
@ -300,9 +301,9 @@ public class IngresDialect extends Dialect {
.register();
// No idea since when this is supported
CommonFunctionFactory.listagg( null, queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.listagg( null );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}

View File

@ -120,36 +120,37 @@ public class MaxDBDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.dateTimeTimestamp( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.week_weekofyear( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.coalesce_value( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.log();
functionFactory.pi();
functionFactory.cot();
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.radians();
functionFactory.degrees();
functionFactory.trunc();
functionFactory.trim2();
functionFactory.substr();
functionFactory.substring_substr();
functionFactory.translate();
functionFactory.initcap();
functionFactory.soundex();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.daynameMonthname();
functionFactory.dateTimeTimestamp();
functionFactory.ceiling_ceil();
functionFactory.week_weekofyear();
functionFactory.concat_pipeOperator();
functionFactory.coalesce_value();
//since lpad/rpad are not actually useful padding
//functions, map them to lfill/rfill
CommonFunctionFactory.pad_fill( queryEngine );
CommonFunctionFactory.datediff( queryEngine );
CommonFunctionFactory.adddateSubdateAddtimeSubtime( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
functionFactory.pad_fill();
functionFactory.datediff();
functionFactory.adddateSubdateAddtimeSubtime();
functionFactory.addMonths();
final BasicType<Integer> integerType = queryEngine.getTypeConfiguration().getBasicTypeRegistry()
.resolve( StandardBasicTypes.INTEGER );

View File

@ -111,16 +111,17 @@ public class MimerSQLDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.pad_repeat( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.localtimeLocaltimestamp( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.soundex();
functionFactory.octetLength();
functionFactory.bitLength();
functionFactory.truncate();
functionFactory.repeat();
functionFactory.pad_repeat();
functionFactory.dayofweekmonthyear();
functionFactory.concat_pipeOperator();
functionFactory.position();
functionFactory.localtimeLocaltimestamp();
}
@Override

View File

@ -169,38 +169,39 @@ public class RDMSOS2200Dialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
// CommonFunctionFactory.replicate( queryEngine ); //synonym for more common repeat()
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.insert( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.cot();
functionFactory.log();
functionFactory.log10();
functionFactory.pi();
functionFactory.rand();
functionFactory.trunc();
functionFactory.truncate();
functionFactory.soundex();
functionFactory.trim2();
functionFactory.space();
functionFactory.repeat();
// functionFactory.replicate(); //synonym for more common repeat()
functionFactory.initcap();
functionFactory.instr();
functionFactory.substr();
functionFactory.translate();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.lastDay();
functionFactory.ceiling_ceil();
functionFactory.concat_pipeOperator();
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.insert();
functionFactory.addMonths();
functionFactory.monthsBetween();
}
@Override

View File

@ -256,20 +256,21 @@ public class SQLiteDialect extends Dialect {
final BasicType<String> stringType = basicTypeRegistry.resolve( StandardBasicTypes.STRING );
final BasicType<Integer> integerType = basicTypeRegistry.resolve( StandardBasicTypes.INTEGER );
CommonFunctionFactory.mod_operator( queryEngine );
CommonFunctionFactory.leftRight_substr( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.characterLength_length( queryEngine, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.leastGreatest_minMax( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.mod_operator();
functionFactory.leftRight_substr();
functionFactory.concat_pipeOperator();
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
functionFactory.leastGreatest_minMax();
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
functionFactory.radians();
functionFactory.degrees();
functionFactory.trunc();
functionFactory.log();
functionFactory.trim2();
functionFactory.substr();
functionFactory.substring_substr();
functionFactory.chr_char();
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"locate",
@ -316,7 +317,7 @@ public class SQLiteDialect extends Dialect {
.setParameterTypes(NUMERIC)
.register();
}
CommonFunctionFactory.listagg_groupConcat( queryEngine );
functionFactory.listagg_groupConcat();
}
@Override

View File

@ -80,7 +80,7 @@ public class SybaseAnywhereDialect extends SybaseDialect {
@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.listagg_list( "varchar", queryEngine );
new CommonFunctionFactory( queryEngine ).listagg_list( "varchar" );
}
@Override

View File

@ -252,15 +252,16 @@ public class TeradataDialect extends Dialect {
final BasicTypeRegistry basicTypeRegistry = queryEngine.getTypeConfiguration().getBasicTypeRegistry();
final BasicType<String> stringType = basicTypeRegistry.resolve( StandardBasicTypes.STRING );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.moreHyperbolic( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.concat_pipeOperator();
functionFactory.octetLength();
functionFactory.moreHyperbolic();
functionFactory.instr();
functionFactory.substr();
functionFactory.substring_substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "octet_length(cast(?1 as char))*4" );
functionFactory.position();
functionFactory.bitLength_pattern( "octet_length(cast(?1 as char))*4" );
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder( "mod", "(?1 mod ?2)" )
.setInvariantType( stringType )
@ -270,23 +271,23 @@ public class TeradataDialect extends Dialect {
if ( getVersion().isSameOrAfter( 14 ) ) {
//list actually taken from Teradata 15 docs
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.moreHyperbolic( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
functionFactory.lastDay();
functionFactory.initcap();
functionFactory.trim2();
functionFactory.soundex();
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.trunc();
functionFactory.moreHyperbolic();
functionFactory.monthsBetween();
functionFactory.addMonths();
functionFactory.stddevPopSamp();
functionFactory.varPopSamp();
}
// No idea since when this is supported
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
/**
@ -489,7 +490,7 @@ public class TeradataDialect extends Dialect {
return getVersion().isBefore( 14 ) ? super.getViolatedConstraintNameExtractor() : EXTRACTOR;
}
private static ViolatedConstraintNameExtractor EXTRACTOR =
private static final ViolatedConstraintNameExtractor EXTRACTOR =
new TemplatedViolatedConstraintNameExtractor( sqle -> {
String constraintName;
switch ( sqle.getErrorCode() ) {

View File

@ -147,20 +147,21 @@ public class TimesTenDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.leftRight_substr( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.rownumRowid( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.trim2();
functionFactory.soundex();
functionFactory.trunc();
functionFactory.toCharNumberDateTimestamp();
functionFactory.ceiling_ceil();
functionFactory.instr();
functionFactory.substr();
functionFactory.substring_substr();
functionFactory.leftRight_substr();
functionFactory.char_chr();
functionFactory.rownumRowid();
functionFactory.sysdate();
functionFactory.addMonths();
functionFactory.monthsBetween();
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
"locate",

View File

@ -282,35 +282,36 @@ public abstract class AbstractHANADialect extends Dialect {
FunctionParameterType.STRING, FunctionParameterType.STRING, FunctionParameterType.INTEGER
).setArgumentListSignature("(pattern, string[, start])");
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.log10_log( queryEngine );
CommonFunctionFactory.bitand( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.characterLength_length( queryEngine, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.addYearsMonthsDaysHoursMinutesSeconds( queryEngine );
CommonFunctionFactory.daysBetween( queryEngine );
CommonFunctionFactory.secondsBetween( queryEngine );
CommonFunctionFactory.format_toVarchar( queryEngine );
CommonFunctionFactory.currentUtcdatetimetimestamp( queryEngine );
CommonFunctionFactory.everyAny_sumCaseCase( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "length(to_binary(?1))*8" );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.ceiling_ceil();
functionFactory.concat_pipeOperator();
functionFactory.trim2();
functionFactory.cot();
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.log10_log();
functionFactory.bitand();
functionFactory.hourMinuteSecond();
functionFactory.yearMonthDay();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.lastDay();
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
functionFactory.daysBetween();
functionFactory.secondsBetween();
functionFactory.format_toVarchar();
functionFactory.currentUtcdatetimetimestamp();
functionFactory.everyAny_sumCaseCase();
functionFactory.bitLength_pattern( "length(to_binary(?1))*8" );
CommonFunctionFactory.listagg_stringAgg( "varchar", queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.listagg_stringAgg( "varchar" );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
@Override

View File

@ -124,30 +124,31 @@ public abstract class AbstractTransactSQLDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.ln_log( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.atan2_atn2( queryEngine );
CommonFunctionFactory.mod_operator( queryEngine );
CommonFunctionFactory.square( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.pad_replicate( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.ascii(queryEngine);
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.concat_plusOperator( queryEngine );
CommonFunctionFactory.trim1( queryEngine );
CommonFunctionFactory.repeat_replicate( queryEngine );
CommonFunctionFactory.characterLength_len( queryEngine );
CommonFunctionFactory.substring_substringLen( queryEngine );
CommonFunctionFactory.datepartDatename( queryEngine );
CommonFunctionFactory.lastDay_eomonth( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.cot();
functionFactory.log();
functionFactory.ln_log();
functionFactory.log10();
functionFactory.atan2_atn2();
functionFactory.mod_operator();
functionFactory.square();
functionFactory.rand();
functionFactory.radians();
functionFactory.degrees();
functionFactory.pi();
functionFactory.reverse();
functionFactory.space();
functionFactory.pad_replicate();
functionFactory.yearMonthDay();
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.concat_plusOperator();
functionFactory.trim1();
functionFactory.repeat_replicate();
functionFactory.characterLength_len();
functionFactory.substring_substringLen();
functionFactory.datepartDatename();
functionFactory.lastDay_eomonth();
queryEngine.getSqmFunctionRegistry().register( "least", new CaseLeastGreatestEmulation( true ) );
queryEngine.getSqmFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );

View File

@ -208,35 +208,36 @@ public class CockroachDialect extends Dialect {
final BasicTypeRegistry basicTypeRegistry = queryEngine.getTypeConfiguration().getBasicTypeRegistry();
final BasicType<String> stringType = basicTypeRegistry.resolve( StandardBasicTypes.STRING );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.overlay( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.substringFromFor( queryEngine );
CommonFunctionFactory.locate_positionSubstring( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.md5( queryEngine );
CommonFunctionFactory.sha1( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.cbrt( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.trunc( queryEngine ); //TODO: emulate second arg
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.overlay();
functionFactory.position();
functionFactory.substringFromFor();
functionFactory.locate_positionSubstring();
functionFactory.trim2();
functionFactory.substr();
functionFactory.reverse();
functionFactory.repeat();
functionFactory.md5();
functionFactory.sha1();
functionFactory.octetLength();
functionFactory.bitLength();
functionFactory.cbrt();
functionFactory.cot();
functionFactory.degrees();
functionFactory.radians();
functionFactory.pi();
functionFactory.trunc(); //TODO: emulate second arg
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("format", "experimental_strftime")
.setInvariantType( stringType )
.setArgumentsValidator( CommonFunctionFactory.formatValidator() )
.setArgumentListSignature("(TEMPORAL datetime as STRING pattern)")
.register();
CommonFunctionFactory.listagg_stringAgg( "string", queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.listagg_stringAgg( "string" );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
@Override

View File

@ -188,19 +188,20 @@ public class DB2Dialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
functionFactory.cot();
functionFactory.degrees();
functionFactory.log();
functionFactory.log10();
functionFactory.radians();
functionFactory.rand();
functionFactory.soundex();
functionFactory.trim2();
functionFactory.space();
functionFactory.repeat();
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "substr" )
.setInvariantType(
queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.STRING )
@ -217,38 +218,38 @@ public class DB2Dialect extends Dialect {
.setParameterTypes(FunctionParameterType.STRING, FunctionParameterType.INTEGER, FunctionParameterType.INTEGER, FunctionParameterType.ANY)
.setArgumentListSignature( "(STRING string{ INTEGER from|,} start[{ INTEGER for|,} length[, units]])" )
.register();
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.bitand( queryEngine );
CommonFunctionFactory.bitor( queryEngine );
CommonFunctionFactory.bitxor( queryEngine );
CommonFunctionFactory.bitnot( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.dateTimeTimestamp( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.insert( queryEngine );
CommonFunctionFactory.overlayCharacterLength_overlay( queryEngine );
CommonFunctionFactory.median( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.stdevVarianceSamp( queryEngine );
CommonFunctionFactory.addYearsMonthsDaysHoursMinutesSeconds( queryEngine );
CommonFunctionFactory.yearsMonthsDaysHoursMinutesSecondsBetween( queryEngine );
CommonFunctionFactory.dateTrunc( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "length(?1)*8" );
functionFactory.translate();
functionFactory.bitand();
functionFactory.bitor();
functionFactory.bitxor();
functionFactory.bitnot();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.lastDay();
functionFactory.toCharNumberDateTimestamp();
functionFactory.dateTimeTimestamp();
functionFactory.concat_pipeOperator();
functionFactory.octetLength();
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.position();
functionFactory.trunc();
functionFactory.truncate();
functionFactory.insert();
functionFactory.overlayCharacterLength_overlay();
functionFactory.median();
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.regrLinearRegressionAggregates();
functionFactory.variance();
functionFactory.stdevVarianceSamp();
functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween();
functionFactory.dateTrunc();
functionFactory.bitLength_pattern( "length(?1)*8" );
queryEngine.getSqmFunctionRegistry().register( "format",
new DB2FormatEmulation( queryEngine.getTypeConfiguration() ) );
@ -263,10 +264,10 @@ public class DB2Dialect extends Dialect {
.register();
if ( getDB2Version().isSameOrAfter( 9, 5 ) ) {
CommonFunctionFactory.listagg( null, queryEngine );
functionFactory.listagg( null );
if ( getDB2Version().isSameOrAfter( 11, 1 ) ) {
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
}
}

View File

@ -46,9 +46,10 @@ public class DB2iDialect extends DB2Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
if ( getVersion().isSameOrAfter( 7, 2 ) ) {
CommonFunctionFactory.listagg( null, queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.listagg( null );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
}

View File

@ -57,9 +57,10 @@ public class DB2zDialect extends DB2Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
if ( getVersion().isSameOrAfter( 12 ) ) {
CommonFunctionFactory.listagg( null, queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.listagg( null );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
}

View File

@ -217,38 +217,39 @@ public class DerbyDialect extends Dialect {
final BasicTypeRegistry basicTypeRegistry = queryEngine.getTypeConfiguration().getBasicTypeRegistry();
final BasicType<String> stringType = basicTypeRegistry.resolve( StandardBasicTypes.STRING );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
// Derby needs an actual argument type for aggregates like SUM, AVG, MIN, MAX to determine the result type
CommonFunctionFactory.aggregates(
functionFactory.aggregates(
this,
queryEngine,
SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER,
"||",
getCastTypeName( stringType, null, null, null )
);
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.trim1( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.leftRight_substrLength( queryEngine );
CommonFunctionFactory.characterLength_length( queryEngine, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
CommonFunctionFactory.power_expLn( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "length(?1)*8" );
functionFactory.concat_pipeOperator();
functionFactory.cot();
functionFactory.chr_char();
functionFactory.degrees();
functionFactory.radians();
functionFactory.log10();
functionFactory.sinh();
functionFactory.cosh();
functionFactory.tanh();
functionFactory.pi();
functionFactory.rand();
functionFactory.trim1();
functionFactory.hourMinuteSecond();
functionFactory.yearMonthDay();
functionFactory.varPopSamp();
functionFactory.stddevPopSamp();
functionFactory.substring_substr();
functionFactory.leftRight_substrLength();
functionFactory.characterLength_length( SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
functionFactory.power_expLn();
functionFactory.bitLength_pattern( "length(?1)*8" );
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder( "round", "floor(?1*1e?2+0.5)/1e?2")
.setReturnTypeResolver( useArgType(1) )

View File

@ -779,15 +779,17 @@ public abstract class Dialect implements ConversionContext {
final BasicType<LocalTime> localTimeType = basicTypeRegistry.resolve( StandardBasicTypes.LOCAL_TIME );
final BasicType<LocalDate> localDateType = basicTypeRegistry.resolve( StandardBasicTypes.LOCAL_DATE );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
//aggregate functions, supported on every database
CommonFunctionFactory.aggregates( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT, "||", null );
functionFactory.aggregates( this, SqlAstNodeRenderingMode.DEFAULT, "||", null );
//the ANSI SQL-defined aggregate functions any() and every() are only
//supported on one database, but can be emulated using sum() and case,
//though there is a more natural mapping on some databases
CommonFunctionFactory.everyAny_sumCase( queryEngine );
functionFactory.everyAny_sumCase();
//math functions supported on almost every database
@ -799,42 +801,42 @@ public abstract class Dialect implements ConversionContext {
//decimal" version of these functions, and if any database attempted
//to implement such a silly thing, it would be dog slow.
CommonFunctionFactory.math( queryEngine );
functionFactory.math();
//trig functions supported on almost every database
CommonFunctionFactory.trigonometry( queryEngine );
functionFactory.trigonometry();
//coalesce() function, supported by most databases, must be emulated
//in terms of nvl() for platforms which don't support it natively
CommonFunctionFactory.coalesce( queryEngine );
functionFactory.coalesce();
//nullif() function, supported on almost every database
CommonFunctionFactory.nullif( queryEngine );
functionFactory.nullif();
//string functions, must be emulated where not supported
CommonFunctionFactory.leftRight( queryEngine );
CommonFunctionFactory.replace( queryEngine );
CommonFunctionFactory.concat( queryEngine );
CommonFunctionFactory.lowerUpper( queryEngine );
functionFactory.leftRight();
functionFactory.replace();
functionFactory.concat();
functionFactory.lowerUpper();
//there are two forms of substring(), the JPA standard syntax, which
//separates arguments using commas, and the ANSI SQL standard syntax
//with named arguments (we support both)
CommonFunctionFactory.substring( queryEngine );
functionFactory.substring();
//the JPA locate() function is especially tricky to emulate, calling
//for lots of Dialect-specific customization
CommonFunctionFactory.locate( queryEngine );
functionFactory.locate();
//JPA string length() function, a synonym for ANSI SQL character_length()
CommonFunctionFactory.length_characterLength( queryEngine );
functionFactory.length_characterLength();
//only some databases support the ANSI SQL-style position() function, so
//define it here as an alias for locate()
@ -870,7 +872,7 @@ public abstract class Dialect implements ConversionContext {
//There is a 'collate' operator in a number of major databases
CommonFunctionFactory.collate( queryEngine );
functionFactory.collate();
//ANSI SQL extract() function is supported on the databases we care most
//about (though it is called datepart() in some of them) but HQL defines
@ -881,7 +883,7 @@ public abstract class Dialect implements ConversionContext {
//comparison functions supported on every known database
CommonFunctionFactory.leastGreatest( queryEngine );
functionFactory.leastGreatest();
//two-argument synonym for coalesce() supported on most but not every
//database, so define it here as an alias for coalesce(arg1,arg2)
@ -892,7 +894,7 @@ public abstract class Dialect implements ConversionContext {
//where not supported, but they're not considered "standard" ... instead
//they're used to implement pad()
CommonFunctionFactory.pad( queryEngine );
functionFactory.pad();
//pad() is a function we've designed to look like ANSI trim()
@ -907,7 +909,7 @@ public abstract class Dialect implements ConversionContext {
//Oracle-style to_char() function, and on others using their native
//formatting functions
CommonFunctionFactory.format_toChar( queryEngine );
functionFactory.format_toChar();
//timestampadd()/timestampdiff() delegated back to the Dialect itself
//since there is a great variety of different ways to emulate them

View File

@ -223,70 +223,72 @@ public class H2Dialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
// H2 needs an actual argument type for aggregates like SUM, AVG, MIN, MAX to determine the result type
CommonFunctionFactory.aggregates( this, queryEngine, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER, "||", null );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.bitand( queryEngine );
CommonFunctionFactory.bitor( queryEngine );
CommonFunctionFactory.bitxor( queryEngine );
CommonFunctionFactory.bitAndOr( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayOfWeekMonthYear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
// H2 needs an actual argument type for aggregates like SUM, AVG, MIN, MAX to determine the result type
functionFactory.aggregates( this, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER, "||", null );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
functionFactory.pi();
functionFactory.cot();
functionFactory.radians();
functionFactory.degrees();
functionFactory.log10();
functionFactory.rand();
functionFactory.truncate();
functionFactory.soundex();
functionFactory.translate();
functionFactory.bitand();
functionFactory.bitor();
functionFactory.bitxor();
functionFactory.bitAndOr();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayOfWeekMonthYear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
if ( useLocalTime ) {
CommonFunctionFactory.localtimeLocaltimestamp( queryEngine );
functionFactory.localtimeLocaltimestamp();
}
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
functionFactory.bitLength();
functionFactory.octetLength();
functionFactory.ascii();
functionFactory.octetLength();
functionFactory.space();
functionFactory.repeat();
functionFactory.chr_char();
functionFactory.instr();
functionFactory.substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.trim1( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.nowCurdateCurtime( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.insert( queryEngine );
// CommonFunctionFactory.everyAny( queryEngine ); //this would work too
CommonFunctionFactory.everyAny_boolAndOr( queryEngine );
CommonFunctionFactory.median( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
functionFactory.position();
functionFactory.trim1();
functionFactory.concat_pipeOperator();
functionFactory.nowCurdateCurtime();
functionFactory.sysdate();
functionFactory.insert();
// functionFactory.everyAny(); //this would work too
functionFactory.everyAny_boolAndOr();
functionFactory.median();
functionFactory.stddevPopSamp();
functionFactory.varPopSamp();
if ( getVersion().isSame( 1, 4, 200 ) ) {
// See https://github.com/h2database/h2database/issues/2518
CommonFunctionFactory.format_toChar( queryEngine );
functionFactory.format_toChar();
}
else {
CommonFunctionFactory.format_formatdatetime( queryEngine );
functionFactory.format_formatdatetime();
}
CommonFunctionFactory.rownum( queryEngine );
functionFactory.rownum();
if ( getVersion().isSameOrAfter( 1, 4, 200 ) ) {
CommonFunctionFactory.listagg( null, queryEngine );
functionFactory.listagg( null );
if ( getVersion().isSameOrAfter( 2 ) ) {
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
}
else {
CommonFunctionFactory.listagg_groupConcat( queryEngine );
functionFactory.listagg_groupConcat();
}
}

View File

@ -167,64 +167,66 @@ public class HSQLDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.bitand( queryEngine );
CommonFunctionFactory.bitor( queryEngine );
CommonFunctionFactory.bitxor( queryEngine );
CommonFunctionFactory.bitnot( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.trim1( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.localtimeLocaltimestamp( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.cot();
functionFactory.radians();
functionFactory.degrees();
functionFactory.log10();
functionFactory.rand();
functionFactory.trunc();
functionFactory.truncate();
functionFactory.pi();
functionFactory.soundex();
functionFactory.reverse();
functionFactory.space();
functionFactory.repeat();
functionFactory.translate();
functionFactory.bitand();
functionFactory.bitor();
functionFactory.bitxor();
functionFactory.bitnot();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.lastDay();
functionFactory.trim1();
functionFactory.toCharNumberDateTimestamp();
functionFactory.concat_pipeOperator();
functionFactory.localtimeLocaltimestamp();
functionFactory.bitLength();
functionFactory.octetLength();
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.instr();
functionFactory.substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.nowCurdateCurtime( queryEngine );
CommonFunctionFactory.insert( queryEngine );
CommonFunctionFactory.overlay( queryEngine );
CommonFunctionFactory.median( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.collate_quoted( queryEngine );
functionFactory.position();
functionFactory.nowCurdateCurtime();
functionFactory.insert();
functionFactory.overlay();
functionFactory.median();
functionFactory.stddevPopSamp();
functionFactory.varPopSamp();
functionFactory.addMonths();
functionFactory.monthsBetween();
functionFactory.collate_quoted();
if ( getVersion().isSameOrAfter( 2 ) ) {
//SYSDATE is similar to LOCALTIMESTAMP but it returns the timestamp when it is called
CommonFunctionFactory.sysdate( queryEngine );
functionFactory.sysdate();
}
// from v. 2.2.0 ROWNUM() is supported in all modes as the equivalent of Oracle ROWNUM
if ( getVersion().isSameOrAfter( 2, 2 ) ) {
CommonFunctionFactory.rownum( queryEngine );
functionFactory.rownum();
}
CommonFunctionFactory.listagg_groupConcat( queryEngine );
functionFactory.listagg_groupConcat();
}
@Override

View File

@ -383,70 +383,72 @@ public class MySQLDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log2( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.pi( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.space( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.pad_space( queryEngine );
CommonFunctionFactory.md5( queryEngine );
CommonFunctionFactory.yearMonthDay( queryEngine );
CommonFunctionFactory.hourMinuteSecond( queryEngine );
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.weekQuarter( queryEngine );
CommonFunctionFactory.daynameMonthname( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.date( queryEngine );
CommonFunctionFactory.timestamp( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.soundex();
functionFactory.radians();
functionFactory.degrees();
functionFactory.cot();
functionFactory.log();
functionFactory.log2();
functionFactory.log10();
functionFactory.pi();
functionFactory.trim2();
functionFactory.octetLength();
functionFactory.reverse();
functionFactory.space();
functionFactory.repeat();
functionFactory.pad_space();
functionFactory.md5();
functionFactory.yearMonthDay();
functionFactory.hourMinuteSecond();
functionFactory.dayofweekmonthyear();
functionFactory.weekQuarter();
functionFactory.daynameMonthname();
functionFactory.lastDay();
functionFactory.date();
functionFactory.timestamp();
time( queryEngine );
CommonFunctionFactory.utcDateTimeTimestamp( queryEngine );
CommonFunctionFactory.rand( queryEngine );
CommonFunctionFactory.crc32( queryEngine );
CommonFunctionFactory.sha1( queryEngine );
CommonFunctionFactory.sha2( queryEngine );
CommonFunctionFactory.sha( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.chr_char( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
functionFactory.utcDateTimeTimestamp();
functionFactory.rand();
functionFactory.crc32();
functionFactory.sha1();
functionFactory.sha2();
functionFactory.sha();
functionFactory.bitLength();
functionFactory.octetLength();
functionFactory.ascii();
functionFactory.chr_char();
functionFactory.instr();
functionFactory.substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.nowCurdateCurtime( queryEngine );
CommonFunctionFactory.truncate( queryEngine );
CommonFunctionFactory.insert( queryEngine );
CommonFunctionFactory.bitandorxornot_operator( queryEngine );
CommonFunctionFactory.bitAndOr( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.datediff( queryEngine );
CommonFunctionFactory.adddateSubdateAddtimeSubtime( queryEngine );
CommonFunctionFactory.format_dateFormat( queryEngine );
CommonFunctionFactory.makedateMaketime( queryEngine );
functionFactory.position();
functionFactory.nowCurdateCurtime();
functionFactory.truncate();
functionFactory.insert();
functionFactory.bitandorxornot_operator();
functionFactory.bitAndOr();
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.variance();
functionFactory.varPopSamp();
functionFactory.datediff();
functionFactory.adddateSubdateAddtimeSubtime();
functionFactory.format_dateFormat();
functionFactory.makedateMaketime();
if ( getMySQLVersion().isBefore( 5, 7 ) ) {
CommonFunctionFactory.sysdateParens( queryEngine );
functionFactory.sysdateParens();
}
else {
// MySQL timestamp type defaults to precision 0 (seconds) but
// we want the standard default precision of 6 (microseconds)
CommonFunctionFactory.sysdateExplicitMicros( queryEngine );
functionFactory.sysdateExplicitMicros();
}
queryEngine.getSqmFunctionRegistry().register( "field", new FieldFunction( queryEngine.getTypeConfiguration() ) );
CommonFunctionFactory.listagg_groupConcat( queryEngine );
functionFactory.listagg_groupConcat();
}
@Override

View File

@ -137,49 +137,50 @@ public class OracleDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10_log( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.instr( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
CommonFunctionFactory.leftRight_substr( queryEngine );
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.bitand( queryEngine );
CommonFunctionFactory.lastDay( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.rownumRowid( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.systimestamp( queryEngine );
CommonFunctionFactory.characterLength_length( queryEngine, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.addMonths( queryEngine );
CommonFunctionFactory.monthsBetween( queryEngine );
CommonFunctionFactory.everyAny_sumCaseCase( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.trunc();
functionFactory.log();
functionFactory.log10_log();
functionFactory.soundex();
functionFactory.trim2();
functionFactory.initcap();
functionFactory.instr();
functionFactory.substr();
functionFactory.substring_substr();
functionFactory.leftRight_substr();
functionFactory.translate();
functionFactory.bitand();
functionFactory.lastDay();
functionFactory.toCharNumberDateTimestamp();
functionFactory.ceiling_ceil();
functionFactory.concat_pipeOperator();
functionFactory.rownumRowid();
functionFactory.sysdate();
functionFactory.systimestamp();
functionFactory.characterLength_length( SqlAstNodeRenderingMode.DEFAULT );
functionFactory.addMonths();
functionFactory.monthsBetween();
functionFactory.everyAny_sumCaseCase();
CommonFunctionFactory.median( queryEngine );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.covarPopSamp( queryEngine );
CommonFunctionFactory.corr( queryEngine );
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "vsize(?1)*8" );
functionFactory.median();
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.variance();
functionFactory.varPopSamp();
functionFactory.covarPopSamp();
functionFactory.corr();
functionFactory.regrLinearRegressionAggregates();
functionFactory.bitLength_pattern( "vsize(?1)*8" );
if ( getVersion().isBefore( 9 ) ) {
queryEngine.getSqmFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
}
else {
//Oracle has had coalesce() since 9.0.1
CommonFunctionFactory.coalesce( queryEngine );
functionFactory.coalesce();
}
queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern(
@ -191,13 +192,13 @@ public class OracleDialect extends Dialect {
).setArgumentListSignature("(pattern, string[, start])");
// The within group clause became optional in 18
if ( getVersion().isSameOrAfter( 18 ) ) {
CommonFunctionFactory.listagg( null, queryEngine );
functionFactory.listagg( null );
}
else {
CommonFunctionFactory.listagg( "within group (order by rownum)", queryEngine );
functionFactory.listagg( "within group (order by rownum)" );
}
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
functionFactory.hypotheticalOrderedSetAggregates();
functionFactory.inverseDistributionOrderedSetAggregates();
// Oracle has a regular aggregate function named stats_mode
queryEngine.getSqmFunctionRegistry().register(
"mode",

View File

@ -402,59 +402,61 @@ public class PostgreSQLDialect extends Dialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.cot( queryEngine );
CommonFunctionFactory.radians( queryEngine );
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.cot();
functionFactory.radians();
functionFactory.degrees();
functionFactory.trunc();
functionFactory.log();
if ( getVersion().isSameOrAfter(12) ) {
CommonFunctionFactory.log10( queryEngine );
functionFactory.log10();
}
else {
queryEngine.getSqmFunctionRegistry().registerAlternateKey( "log10", "log" );
}
CommonFunctionFactory.cbrt( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.md5( queryEngine );
CommonFunctionFactory.initcap( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
functionFactory.cbrt();
functionFactory.trim2();
functionFactory.octetLength();
functionFactory.repeat();
functionFactory.md5();
functionFactory.initcap();
functionFactory.substr();
functionFactory.substring_substr();
//also natively supports ANSI-style substring()
CommonFunctionFactory.translate( queryEngine );
CommonFunctionFactory.toCharNumberDateTimestamp( queryEngine );
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.localtimeLocaltimestamp( queryEngine );
CommonFunctionFactory.dateTrunc( queryEngine );
CommonFunctionFactory.bitLength( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );
CommonFunctionFactory.ascii( queryEngine );
CommonFunctionFactory.char_chr( queryEngine );
CommonFunctionFactory.position( queryEngine );
CommonFunctionFactory.bitandorxornot_operator( queryEngine );
CommonFunctionFactory.bitAndOr( queryEngine );
CommonFunctionFactory.everyAny_boolAndOr( queryEngine );
CommonFunctionFactory.median_percentileCont( queryEngine, false );
CommonFunctionFactory.stddev( queryEngine );
CommonFunctionFactory.stddevPopSamp( queryEngine );
CommonFunctionFactory.variance( queryEngine );
CommonFunctionFactory.varPopSamp( queryEngine );
CommonFunctionFactory.covarPopSamp( queryEngine );
CommonFunctionFactory.corr( queryEngine );
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
CommonFunctionFactory.insert_overlay( queryEngine );
CommonFunctionFactory.overlay( queryEngine );
CommonFunctionFactory.soundex( queryEngine ); //was introduced in Postgres 9 apparently
functionFactory.translate();
functionFactory.toCharNumberDateTimestamp();
functionFactory.concat_pipeOperator();
functionFactory.localtimeLocaltimestamp();
functionFactory.dateTrunc();
functionFactory.bitLength();
functionFactory.octetLength();
functionFactory.ascii();
functionFactory.char_chr();
functionFactory.position();
functionFactory.bitandorxornot_operator();
functionFactory.bitAndOr();
functionFactory.everyAny_boolAndOr();
functionFactory.median_percentileCont( false );
functionFactory.stddev();
functionFactory.stddevPopSamp();
functionFactory.variance();
functionFactory.varPopSamp();
functionFactory.covarPopSamp();
functionFactory.corr();
functionFactory.regrLinearRegressionAggregates();
functionFactory.insert_overlay();
functionFactory.overlay();
functionFactory.soundex(); //was introduced in Postgres 9 apparently
CommonFunctionFactory.locate_positionSubstring( queryEngine );
CommonFunctionFactory.listagg_stringAgg( "varchar", queryEngine );
functionFactory.locate_positionSubstring();
functionFactory.listagg_stringAgg( "varchar" );
if ( getVersion().isSameOrAfter( 9, 4 ) ) {
CommonFunctionFactory.makeDateTimeTimestamp( queryEngine );
functionFactory.makeDateTimeTimestamp();
// Note that PostgreSQL doesn't support the OVER clause for ordered set-aggregate functions
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
}

View File

@ -46,10 +46,11 @@ public class PostgresPlusDialect extends PostgreSQLDialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.rownumRowid( queryEngine );
CommonFunctionFactory.sysdate( queryEngine );
CommonFunctionFactory.systimestamp( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.soundex();
functionFactory.rownumRowid();
functionFactory.sysdate();
functionFactory.systimestamp();
// queryEngine.getSqmFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );

View File

@ -209,20 +209,22 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
BasicType<Date> timeType = basicTypeRegistry.resolve( StandardBasicTypes.TIME );
BasicType<Date> timestampType = basicTypeRegistry.resolve( StandardBasicTypes.TIMESTAMP );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
// For SQL-Server we need to cast certain arguments to varchar(max) to be able to concat them
CommonFunctionFactory.aggregates( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT, "+", "varchar(max)" );
functionFactory.aggregates( this, SqlAstNodeRenderingMode.DEFAULT, "+", "varchar(max)" );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
CommonFunctionFactory.truncate_round( queryEngine );
CommonFunctionFactory.everyAny_sumIif( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "datalength(?1) * 8" );
functionFactory.truncate_round();
functionFactory.everyAny_sumIif();
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
if ( getVersion().isSameOrAfter( 10 ) ) {
CommonFunctionFactory.locate_charindex( queryEngine );
CommonFunctionFactory.stddevPopSamp_stdevp( queryEngine );
CommonFunctionFactory.varPopSamp_varp( queryEngine );
functionFactory.locate_charindex();
functionFactory.stddevPopSamp_stdevp();
functionFactory.varPopSamp_varp();
}
if ( getVersion().isSameOrAfter( 11 ) ) {
@ -230,9 +232,9 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
//actually translate() was added in 2017 but
//it's not worth adding a new dialect for that!
CommonFunctionFactory.translate( queryEngine );
functionFactory.translate();
CommonFunctionFactory.median_percentileCont( queryEngine, true );
functionFactory.median_percentileCont( true );
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "datefromparts" )
.setInvariantType( dateType )
@ -265,10 +267,10 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
.setParameterTypes(INTEGER)
.register();
}
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
if ( getVersion().isSameOrAfter( 14 ) ) {
CommonFunctionFactory.listagg_stringAggWithinGroup( "varchar(max)", queryEngine );
functionFactory.listagg_stringAggWithinGroup( "varchar(max)" );
}
}

View File

@ -179,17 +179,19 @@ public class SpannerDialect extends Dialect {
.setArgumentCountBetween( 1, 2 )
.register();
// Mathematical Functions
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.ceiling_ceil( queryEngine );
CommonFunctionFactory.cosh( queryEngine );
CommonFunctionFactory.sinh( queryEngine );
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.moreHyperbolic( queryEngine );
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
CommonFunctionFactory.bitandorxornot_bitAndOrXorNot( queryEngine );
// Mathematical Functions
functionFactory.log();
functionFactory.log10();
functionFactory.trunc();
functionFactory.ceiling_ceil();
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.moreHyperbolic();
functionFactory.bitandorxornot_bitAndOrXorNot();
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "is_inf" )
.setInvariantType( booleanType )
@ -208,7 +210,7 @@ public class SpannerDialect extends Dialect {
.setExactArgumentCount( 2 )
.register();
CommonFunctionFactory.sha1( queryEngine );
functionFactory.sha1();
// Hash Functions
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "farm_fingerprint" )
@ -225,12 +227,12 @@ public class SpannerDialect extends Dialect {
.register();
// String Functions
CommonFunctionFactory.concat_pipeOperator( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.reverse( queryEngine );
CommonFunctionFactory.repeat( queryEngine );
CommonFunctionFactory.substr( queryEngine );
CommonFunctionFactory.substring_substr( queryEngine );
functionFactory.concat_pipeOperator();
functionFactory.trim2();
functionFactory.reverse();
functionFactory.repeat();
functionFactory.substr();
functionFactory.substring_substr();
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "byte_length" )
.setInvariantType( longType )
.setExactArgumentCount( 1 )
@ -427,9 +429,9 @@ public class SpannerDialect extends Dialect {
.setArgumentsValidator( CommonFunctionFactory.formatValidator() )
.setArgumentListSignature("(TIMESTAMP datetime as STRING pattern)")
.register();
CommonFunctionFactory.listagg_stringAgg( "string", queryEngine );
CommonFunctionFactory.inverseDistributionOrderedSetAggregates( queryEngine );
CommonFunctionFactory.hypotheticalOrderedSetAggregates( queryEngine );
functionFactory.listagg_stringAgg( "string" );
functionFactory.inverseDistributionOrderedSetAggregates();
functionFactory.hypotheticalOrderedSetAggregates();
}
@Override

View File

@ -205,20 +205,22 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry(queryEngine);
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
// For SQL-Server we need to cast certain arguments to varchar(16384) to be able to concat them
CommonFunctionFactory.aggregates( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT, "+", "varchar(16384)" );
functionFactory.aggregates( this, SqlAstNodeRenderingMode.DEFAULT, "+", "varchar(16384)" );
// AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
CommonFunctionFactory.avg_castingNonDoubleArguments( this, queryEngine, SqlAstNodeRenderingMode.DEFAULT );
functionFactory.avg_castingNonDoubleArguments( this, SqlAstNodeRenderingMode.DEFAULT );
//this doesn't work 100% on earlier versions of Sybase
//which were missing the third parameter in charindex()
//TODO: we could emulate it with substring() like in Postgres
CommonFunctionFactory.locate_charindex( queryEngine );
functionFactory.locate_charindex();
CommonFunctionFactory.replace_strReplace( queryEngine );
CommonFunctionFactory.everyAny_sumCaseCase( queryEngine );
CommonFunctionFactory.bitLength_pattern( queryEngine, "datalength(?1) * 8" );
functionFactory.replace_strReplace();
functionFactory.everyAny_sumCaseCase();
functionFactory.bitLength_pattern( "datalength(?1) * 8" );
}
@Override

View File

@ -11,8 +11,6 @@ import jakarta.persistence.TemporalType;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
import org.hibernate.sql.ast.SqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlAppender;