Skip to content

Commit

Permalink
make extract() function work on Cache
Browse files Browse the repository at this point in the history
map it to datepart()
  • Loading branch information
gavinking authored and sebersole committed May 8, 2019
1 parent b4a218c commit a31d6f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Expand Up @@ -74,6 +74,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
CommonFunctionFactory.repeat_replicate( queryEngine );
CommonFunctionFactory.leftRight( queryEngine );
CommonFunctionFactory.characterLength_len( queryEngine );
CommonFunctionFactory.extract_datepart( queryEngine );

queryEngine.getSqmFunctionRegistry().namedTemplateBuilder( "square" )
.setExactArgumentCount( 1 )
Expand All @@ -92,11 +93,6 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
.setExactArgumentCount( 1 )
.register();

queryEngine.getSqmFunctionRegistry().namedTemplateBuilder( "extract", "datepart" )
.setInvariantType( StandardSpiBasicTypes.INTEGER )
.setExactArgumentCount( 2 )
.register();

queryEngine.getSqmFunctionRegistry().patternTemplateBuilder( "mod", "(?1 % ?2)" )
.setInvariantType( StandardSpiBasicTypes.INTEGER )
.setExactArgumentCount( 2 )
Expand Down
Expand Up @@ -272,6 +272,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
CommonFunctionFactory.dayofweekmonthyear( queryEngine );
CommonFunctionFactory.repeat_replicate( queryEngine );
CommonFunctionFactory.leftRight( queryEngine );
CommonFunctionFactory.extract_datepart( queryEngine );

PairedFunctionTemplate.register(queryEngine, "locate", StandardSpiBasicTypes.INTEGER, "$find(?2, ?1)", "$find(?2, ?1, ?3)");

Expand Down
Expand Up @@ -624,6 +624,14 @@ public static void extract(QueryEngine queryEngine) {
.register();
}

public static void extract_datepart(QueryEngine queryEngine) {
queryEngine.getSqmFunctionRegistry().namedTemplateBuilder( "datepart" )
.setInvariantType( StandardSpiBasicTypes.INTEGER )
.setExactArgumentCount( 2 )
.register();
queryEngine.getSqmFunctionRegistry().registerAlternateKey( "extract", "datepart ");
}

public static void cast(QueryEngine queryEngine) {
queryEngine.getSqmFunctionRegistry().patternTemplateBuilder("cast", "cast(?1 as ?2)")
.setExactArgumentCount(2)
Expand Down Expand Up @@ -778,4 +786,5 @@ public static void sha(QueryEngine queryEngine) {
.setExactArgumentCount( 1 )
.register();
}

}

0 comments on commit a31d6f3

Please sign in to comment.