Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new DateTime functions #705

Merged
merged 188 commits into from Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 184 commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
a5b4fde
Merge branch 'releasing/v5.0' into version5
bcogrel Feb 20, 2023
2fe9dbf
Update property_description.json
bcogrel Feb 20, 2023
6a6d6da
Changed UnionNodeImpl inferUniqueConstraints method to add disjoint c…
DRovara Feb 23, 2023
0ebb4eb
Initial version of UnionTest with some basic tests
DRovara Feb 23, 2023
e1079f5
Merge branch 'version5' into feature/substitution-refactoring
kontchakov Feb 24, 2023
e70c100
Merge branch 'releasing/v5.0' into version5
bcogrel Feb 24, 2023
a0ccc82
Merge branch 'releasing/v5.0' into version5
bcogrel Feb 27, 2023
18618f1
Added more testcases for UnionLens, fixed bug that sometimes didn't r…
DRovara Mar 1, 2023
435c9bd
Merge branch 'version5' into feature/substitution-refactoring
kontchakov Mar 1, 2023
a40ec73
Cleanup in code
DRovara Mar 1, 2023
62708b1
Removed unused variable
DRovara Mar 1, 2023
6e3f7b0
Changed some test case expected results that were outdated with the n…
DRovara Mar 1, 2023
adfee7e
Changed UnionNode implementation so that unique constraints only add …
DRovara Mar 2, 2023
effc476
Simplified inferUniqueConstraints method in UnionNode
DRovara Mar 2, 2023
6824db2
Changed comments in inferUniqueConstraints
DRovara Mar 2, 2023
21b8a34
reduced interface inclusions and cleaned up a raw type
kontchakov Mar 2, 2023
7c9ec17
Added shortcut to inferUniqueConstraints: if all UCs are disjoint, we…
DRovara Mar 2, 2023
7229804
Merge branch 'feature/union-lens' of github.com:DRovara/ontop into DR…
bcogrel Mar 2, 2023
777b689
Merge branch 'DRovara-feature/union-lens' into version5
bcogrel Mar 3, 2023
5349a4e
Merge branch 'version5' into feature/substitution-refactoring
kontchakov Mar 3, 2023
51c83b3
JsonUnionLens revision
kontchakov Mar 3, 2023
8cd54bb
Merge branch 'feature/substitution-refactoring' into version5
kontchakov Mar 7, 2023
e6daf13
Merge branch 'releasing/v5.0' into version5
bcogrel Mar 9, 2023
7b00abb
Normalizer updated to use Substitution instead of ImmutableSubstitution.
bcogrel Mar 9, 2023
14ff3e6
Merge branch 'releasing/v5.0' into version5
bcogrel Mar 15, 2023
95fe2df
Implemented new FlattenLens that no longer supports access of specifi…
DRovara Mar 17, 2023
3b150e0
Implemented FlattenLens support for SparkSQL. Also added new type of …
DRovara Mar 17, 2023
6bd6533
Merge branch 'feature/flatten-lens-refactoring' into feature/flatten-…
DRovara Mar 17, 2023
178f2fc
Applied new FlattenNode logic to Spark
DRovara Mar 20, 2023
091cc36
Initial implementation of using the ARRAY<T> type in Spark for the Fl…
DRovara Mar 21, 2023
ef224b7
Finalised support for generic array types in Spark
DRovara Mar 21, 2023
afb89eb
Merge branch 'releasing/v5.0' into version5
bcogrel Mar 21, 2023
3f03068
Merge pull request #622 from ontop/feature/flatten-lens-refactoring
bcogrel Mar 21, 2023
4378e90
Added support for the Array type in postgres. Added postgres lightwei…
DRovara Mar 23, 2023
82b3693
First part of Dremio Flatten Lens implementation
DRovara Mar 24, 2023
779017c
Version set to 5.1.0-SNAPSHOT
bcogrel Mar 24, 2023
57da429
Fixed typo in lens file
DRovara Mar 24, 2023
f94a5ef
Merge pull request #625 from ontop/feature/flatten-lens-spark
bcogrel Mar 24, 2023
75e30ae
XSD cast functions
apano-on Mar 22, 2023
ada4cc7
Minor changes
apano-on Mar 24, 2023
8c46b03
RDF datatype string now lifts IF-ELSE-NULL.
bcogrel Mar 26, 2023
433d4e1
cast fs more robuts and pattern check fixes
apano-on Mar 26, 2023
804742a
Added FlattenNode support for Postgres Array types. Also rewrote the …
DRovara Mar 27, 2023
42f744a
Merge branch 'version5' of https://github.com/ontop/ontop into featur…
DRovara Mar 27, 2023
d36df5f
Merge branch 'feature/postgres-array' into feature/dremio-flatten-lens
DRovara Mar 27, 2023
2f34133
Fixed type in Postgres test cases
DRovara Mar 27, 2023
2b74968
Fixed imports in Postgres Nested tests
DRovara Mar 28, 2023
d5223e3
Merge pull request #628 from ontop/feature/postgres-array
bcogrel Mar 28, 2023
500219f
Add and test support for more databases
apano-on Mar 27, 2023
efb174d
Implemented FlattenLens for dremio LISTs (currently, object access is…
DRovara Mar 28, 2023
6c8c7b3
Disable Dremio XSD Cast CI tests
apano-on Mar 28, 2023
532d961
Minor change
apano-on Mar 28, 2023
4481619
Merge branch 'version5' of https://github.com/ontop/ontop into featur…
DRovara Mar 28, 2023
660529f
Removed outdated comment
DRovara Mar 28, 2023
8817a04
Added initial implementation of 'ignoreInvalidMappingEntries' option
DRovara Mar 28, 2023
bd33b10
xsd:decimal cast rejects input with scientific notation
apano-on Mar 28, 2023
e65e0a4
Merge pull request #629 from ontop/feature/dremio-flatten-lens
bcogrel Mar 28, 2023
5cbf4d3
Merge remote-tracking branch 'origin/version5' into feature/xsd-funct…
apano-on Mar 28, 2023
a0337b2
revert logback
apano-on Mar 28, 2023
0d21358
refactor to improve readability and robustness of pattern and version…
apano-on Mar 28, 2023
7b323a6
Added test case for invalid mapping entries, added description of pro…
DRovara Mar 29, 2023
1766caf
Fixed an issue with dremio, where VALUES clauses with integer constan…
DRovara Mar 29, 2023
7e23812
Cleaned up code for DremioSelectFromWhereSerializer to minimize copie…
DRovara Mar 30, 2023
ff38235
Implemented FlattenLens for DuckDB
DRovara Mar 30, 2023
8cd117d
Removed unused variable
DRovara Mar 30, 2023
cb7b149
Implemented FlattenLens for Trino
DRovara Mar 30, 2023
4f00675
No test cases for presto, but implementation should work for it too
DRovara Mar 31, 2023
2844a7d
Implemented array access for dremio, using a workaround
DRovara Mar 31, 2023
1ea1a6c
Implemented FlattenLens for Athena
DRovara Apr 3, 2023
4c61a7b
Added comment on method, where we now use the flattened type provide…
DRovara Apr 3, 2023
45a9f04
Used cast function instead of '::' in lenses
DRovara Apr 3, 2023
ee05b5b
Cleaned up implementation of Array Access Function Symbol
DRovara Apr 3, 2023
a81504d
Merge branch 'version5' of https://github.com/ontop/ontop into featur…
DRovara Apr 3, 2023
37ff72f
Added FunctionSymbol type for Dremio's array access epression. Increa…
DRovara Apr 3, 2023
7b0a7d0
Changed mistake in DremioArrayAccessDBFunctionSymbol
DRovara Apr 3, 2023
70414ee
Merge pull request #630 from ontop/feature/xsd-functions
bcogrel Apr 4, 2023
cd83458
Merge pull request #631 from ontop/feature/ignore-mapping-errors
bcogrel Apr 4, 2023
e15416d
Merge pull request #632 from ontop/bugfix/dremio-type-compatibility
bcogrel Apr 4, 2023
fe69d9c
Merge pull request #633 from ontop/feature/duckdb-flatten-lens
bcogrel Apr 4, 2023
c2632d8
Merge pull request #635 from ontop/feature/trino-flatten-lens
bcogrel Apr 4, 2023
fc43c0e
Merge branch 'version5' into feature/dremio-array-acces
bcogrel Apr 4, 2023
c88ad0f
Merge branch 'releasing/v5.0' into version5
bcogrel Apr 4, 2023
56fcc14
Implemented feature to toggle the use of '[]' for array access in the…
DRovara Apr 5, 2023
322442b
Implemented a common base structure for FlattenNode implementation in…
DRovara Apr 5, 2023
e418da4
Changed square bracket quotation/array access flag to quotedIDFactory
DRovara Apr 5, 2023
c05f8dd
Implemented FlattenLens for BigQuery
DRovara Apr 5, 2023
41c155f
Implemented FlattenLens for MariaDB
DRovara Apr 5, 2023
ef22ce4
Implemented FlattenLens for MySQL
DRovara Apr 5, 2023
a83b699
Added comments to MariaDB/MySQL serializers
DRovara Apr 5, 2023
22e322e
Implemented FlattenLens for SQLServer
DRovara Apr 6, 2023
3d7c9a2
Added a comment for clarification
DRovara Apr 6, 2023
640aa90
Merge pull request #637 from ontop/feature/flatten-lens-cleanup
bcogrel Apr 6, 2023
15c0e42
Initial implementation of Oracle Flatten Lens
DRovara Apr 6, 2023
e17772d
Merge branch 'version5' of https://github.com/ontop/ontop into featur…
DRovara Apr 6, 2023
6eaf406
DBMetadataException can now also be captured.
bcogrel Apr 7, 2023
91ec695
Fixed an issue caused by previous merge
DRovara Apr 11, 2023
4d65bde
Implemented FlattenLens for Oracle
DRovara Apr 11, 2023
5443daa
Added test case for ignored MetadataExtractionExceptions
DRovara Apr 11, 2023
891c45f
Merge branch 'version5' of https://github.com/ontop/ontop into featur…
DRovara Apr 11, 2023
10e2e85
Merge pull request #636 from ontop/feature/dremio-array-acces
bcogrel Apr 11, 2023
cf4f88a
Merge pull request #638 from ontop/feature/bigquery-flatten-lens
bcogrel Apr 11, 2023
6804fcd
Merge branch 'version5' of https://github.com/ontop/ontop into temp
DRovara Apr 11, 2023
41d9688
New version of MariaDB requires a Cast around the expression, otherw…
DRovara Apr 11, 2023
bdae5ab
Merge pull request #639 from ontop/feature/mariadb-mysql-mssql-flatte…
bcogrel Apr 12, 2023
38d3741
Merge pull request #640 from ontop/feature/oracle-flatten-lens
bcogrel Apr 12, 2023
27e0768
Merge branch 'feature/ignore-db-metadata-exception-for-mapping-entry'…
bcogrel Apr 12, 2023
ff05739
Implemented FlattenLens for Redshift
DRovara Apr 13, 2023
c54b86a
Fixed flatten serializer comment
DRovara Apr 13, 2023
33482bd
Merge branch 'feature/redshift-flatten-lens' into version5
bcogrel Apr 13, 2023
5c73787
Also runtime exceptions can now be ignored when processing mapping.
bcogrel Apr 13, 2023
91dad32
Implemented FlattenLens for Snowflake
DRovara Apr 14, 2023
1fe9c2d
Made dummy variales robus so that they do not override any other vari…
DRovara Apr 14, 2023
820bee8
Added FlattenNode unique constraint inference feature
DRovara Apr 17, 2023
8956281
Changed NestedViewPersonTest to adhere to new UC strategy
DRovara Apr 17, 2023
f35eb78
Foreign keys to the source are now also inferred for FlattenLenses
DRovara Apr 17, 2023
f45a776
Merge pull request #642 from ontop/feature/snowflake-flatten-lens
bcogrel Apr 19, 2023
bff435c
Merge pull request #643 from ontop/feature/flatten-node-unique-constr…
bcogrel Apr 19, 2023
dadfe84
Added STRING type to DuckDB
DRovara Apr 20, 2023
7d39681
Removed .wal file for ontop duckdb database
DRovara Apr 20, 2023
1e97029
Merge pull request #646 from ontop/bugfix/duckdb-fixes-for-tutorial
bcogrel Apr 20, 2023
9cf7fd5
Added try/catch block to individual target atoms for mapping error ig…
DRovara Apr 21, 2023
9ad3e47
Replaced 'POSITION' function with 'INSTR' for SparkSQL
DRovara Apr 21, 2023
3c92706
Merge pull request #647 from ontop/bugfix/sparksql-use-instr
bcogrel Apr 21, 2023
87239d6
Changed implementation so that the same exception is not caught twice
DRovara Apr 21, 2023
b2e2e20
Merge pull request #648 from ontop/bugfix/ignore-incorrect-mapping-en…
bcogrel Apr 21, 2023
ec48f24
Addresses #649
fracorco Apr 24, 2023
8b03692
Fixes issue in RDF4JTupleExprTranslator that made UNIONS fail under c…
DRovara May 9, 2023
2ca4cb8
Disabled failing athena test cases as they are not related to this ch…
DRovara May 9, 2023
fa5f755
Merge pull request #651 from ontop/bugfix/issue-627
bcogrel May 9, 2023
aff135f
Found a possible fix for the issue by repeating the fetch procedure i…
DRovara May 9, 2023
4be873d
Merge pull request #650 from ontop/bugfix/docker-read-cli-args-from-file
bcogrel May 9, 2023
c0a0991
Merge branch 'version5' of https://github.com/ontop/ontop into bugfix…
DRovara May 9, 2023
6970564
Added test case for the issue
DRovara May 9, 2023
846d744
Merge pull request #652 from ontop/bugfix/construct-empty-issue
bcogrel May 9, 2023
e81305d
Added new test case for the issue
DRovara May 9, 2023
4481d6a
a fix to empty/incorrect triples
kontchakov May 9, 2023
15722f5
added comments
kontchakov May 9, 2023
28c0711
added handling of incorrect RDF constructs from SPARQL 1.1 spec
kontchakov May 9, 2023
6abc5e7
minor code improvements
kontchakov May 9, 2023
14a77b7
Merge branch 'bugfix/construct-empty-issue2' into 'version5'
May 10, 2023
933ec4a
Added exception if directory for --separate-files materialization doe…
DRovara May 11, 2023
ca3e135
Merge pull request #654 from ontop/bugfix/issue-627-testcase
bcogrel May 11, 2023
f5c7102
Merge pull request #655 from ontop/feature/materialize-handle-directory
bcogrel May 11, 2023
74da9e5
Merge branch 'version5' of gitlab.inf.unibz.it:ontop/ontop into version5
bcogrel May 11, 2023
054480d
Fixed issue that made lenses lose UCs under certain conditions
DRovara May 12, 2023
5b48810
Changed expected results in NestedViewsPersonTest, as we will now fin…
DRovara May 12, 2023
157a652
Added missing cast functions to if-branch without primary keys
DRovara May 12, 2023
c2f6730
Added helper function for shared functionality
DRovara May 15, 2023
ed9b14f
Merge pull request #656 from ontop/bugfix/lenses-lost-ucs
bcogrel May 17, 2023
90544ac
Merge pull request #657 from ontop/bugfix/issue-593
bcogrel May 17, 2023
6d8ef38
Implemented new timestamp extraction functions and tested them for al…
DRovara May 26, 2023
0802101
Implemented new timestamp extraction functions and tested them for al…
DRovara May 26, 2023
56974cf
Also tested and fixed for Athena and Snowflake
DRovara May 26, 2023
5e11a4c
Also tested and fixed for Athena and Snowflake
DRovara May 26, 2023
316967f
New date extract functions implemented and tested for ALL dialects
DRovara May 26, 2023
a154827
New date extract functions implemented and tested for ALL dialects
DRovara May 26, 2023
316d83b
Added DATE_TRUNC function and test case, working for postgres
DRovara May 31, 2023
0dfd98e
Added DATE_TRUNC function and test case, working for postgres
DRovara May 31, 2023
a71c40b
Implemented new IsTrue Function Symbol for Oracle, implemented date_t…
DRovara May 31, 2023
67d7f88
Implemented new IsTrue Function Symbol for Oracle, implemented date_t…
DRovara May 31, 2023
48f6569
Implemented date_trunc for snowflake & athena
DRovara May 31, 2023
b0d043f
Implemented date_trunc for snowflake & athena
DRovara May 31, 2023
b6594c6
Added functionality for bigquery. Redshift should also work, but not …
DRovara May 31, 2023
b7f223e
Added functionality for bigquery. Redshift should also work, but not …
DRovara May 31, 2023
0d4ba6a
Possibly fixed some failing test cases
DRovara Jun 1, 2023
c841bf3
Possibly fixed some failing test cases
DRovara Jun 1, 2023
a89277f
Fixed test case for snowflake
DRovara Jun 1, 2023
7ea8d15
Fixed test case for snowflake
DRovara Jun 1, 2023
396e2cb
Possibly fixed postgres issue
DRovara Jun 1, 2023
9280ed3
Possibly fixed postgres issue
DRovara Jun 1, 2023
be3f79e
Disabled non-supported test case for MySQL and MariaDB
DRovara Jun 1, 2023
4e60af2
Disabled non-supported test case for MySQL and MariaDB
DRovara Jun 1, 2023
7aafc7a
Fixed test case for trino
DRovara Jun 1, 2023
58c94fe
Fixed test case for trino
DRovara Jun 1, 2023
b087764
Distinguished intermediate functions for date_trunc and timestamp_trunc
DRovara Jun 9, 2023
78594f1
Distinguished intermediate functions for date_trunc and timestamp_trunc
DRovara Jun 9, 2023
8554da2
Reworked date_trunc function symbol
DRovara Jun 15, 2023
cebe78c
Reworked date_trunc function symbol
DRovara Jun 15, 2023
3c2f1a0
Fixed dremio test case
DRovara Jun 16, 2023
a05b35a
Merge branch 'feature/new-datetime-functions' of https://github.com/o…
DRovara Jul 12, 2023
f779fd1
<Merge branch 'version5' into feature/new-datetime-functions
DRovara Jul 12, 2023
7e8cb67
Fixed datetrunc issues that were caused by merge
DRovara Jul 12, 2023
77e5c1b
Fixed Trino problem caused by merge, fixed error in dremio test case
DRovara Jul 12, 2023
f5c8c62
Changed exceptions thrown in DateTruncSPARQLFunctionSymbolImpl, used …
DRovara Jul 13, 2023
9f48bf9
Merge branch 'version5' into feature/new-datetime-functions
bcogrel Jul 13, 2023
17b49ae
Minor import fixed.
bcogrel Jul 13, 2023
40e22de
AbstractBindTestWithFunctions updated to refer to a RuntimeException.
bcogrel Jul 13, 2023
37a1e36
Minor test update
bcogrel Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -643,4 +643,17 @@ ImmutableFunctionalTerm getBinaryLatelyTypedFunctionalTerm(
ImmutableExpression getDBJsonIsNumber(DBTermType dbType, ImmutableTerm arg);
ImmutableExpression getDBJsonIsScalar(DBTermType dbType, ImmutableTerm arg);
ImmutableExpression getDBIsArray(DBTermType dbType, ImmutableTerm arg);


// Ontop-defined functions

ImmutableFunctionalTerm getDBWeek(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBQuarter(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBDecade(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBCentury(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBMillennium(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBMilliseconds(ImmutableTerm dbDatetimeTerm);
ImmutableFunctionalTerm getDBMicroseconds(ImmutableTerm dbDatetimeTerm);

ImmutableFunctionalTerm getDBDateTrunc(ImmutableTerm dbDatetimeTerm, ImmutableTerm datePartTerm, String datePart);
}
Expand Up @@ -5,7 +5,6 @@
import it.unibz.inf.ontop.model.term.functionsymbol.FunctionSymbol;
import it.unibz.inf.ontop.model.term.functionsymbol.InequalityLabel;
import it.unibz.inf.ontop.model.type.DBTermType;
import it.unibz.inf.ontop.model.type.GenericDBTermType;
import it.unibz.inf.ontop.model.type.RDFTermType;
import org.apache.commons.rdf.api.IRI;

Expand Down Expand Up @@ -392,4 +391,14 @@ public interface DBFunctionSymbolFactory {
DBFunctionSymbol checkAndConvertDateFromDatetime();
DBFunctionSymbol checkAndConvertDateFromString();


DBFunctionSymbol getDBWeek();
DBFunctionSymbol getDBQuarter();
DBFunctionSymbol getDBDecade();
DBFunctionSymbol getDBCentury();
DBFunctionSymbol getDBMillennium();
DBFunctionSymbol getDBMilliseconds();
DBFunctionSymbol getDBMicroseconds();

DBFunctionSymbol getDBDateTrunc(String datePart);
}
Expand Up @@ -85,6 +85,23 @@ public abstract class AbstractDBFunctionSymbolFactory implements DBFunctionSymbo
private DBFunctionSymbol minutesFunctionSymbol;
// Created in init()
private DBFunctionSymbol secondsFunctionSymbol;
//Created in init
private DBFunctionSymbol weekFunctionSymbol;
//Created in init
private DBFunctionSymbol quarterFunctionSymbol;
//Created in init
private DBFunctionSymbol decadeFunctionSymbol;
//Created in init
private DBFunctionSymbol centuryFunctionSymbol;
//Created in init
private DBFunctionSymbol millenniumFunctionSymbol;
//Created in init
private DBFunctionSymbol millisecondsFunctionSymbol;
//Created in init
private DBFunctionSymbol microsecondsFunctionSymbol;
//Created in init
private DBFunctionSymbol dateTruncFunctionSymbol;
//Created in init
// Created in init()
private DBFunctionSymbol tzFunctionSymbol;

Expand Down Expand Up @@ -429,6 +446,14 @@ protected void init() {
hoursFunctionSymbol = createHoursFunctionSymbol();
minutesFunctionSymbol = createMinutesFunctionSymbol();
secondsFunctionSymbol = createSecondsFunctionSymbol();
weekFunctionSymbol = createWeekFunctionSymbol();
quarterFunctionSymbol = createQuarterFunctionSymbol();
decadeFunctionSymbol = createDecadeFunctionSymbol();
centuryFunctionSymbol = createCenturyFunctionSymbol();
millenniumFunctionSymbol = createMillenniumFunctionSymbol();
millisecondsFunctionSymbol = createMillisecondsFunctionSymbol();
microsecondsFunctionSymbol = createMicrosecondsFunctionSymbol();
dateTruncFunctionSymbol = createDateTruncFunctionSymbol();
tzFunctionSymbol = createTzFunctionSymbol();

weeksBetweenFromDateTimeFunctionSymbol = createWeeksBetweenFromDateTimeFunctionSymbol();
Expand Down Expand Up @@ -974,6 +999,46 @@ public DBFunctionSymbol getDBHours() {
return hoursFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBWeek() {
return weekFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBQuarter() {
return quarterFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBCentury() {
return centuryFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBDecade() {
return decadeFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBMillennium() {
return millenniumFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBMilliseconds() {
return millisecondsFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBMicroseconds() {
return microsecondsFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBDateTrunc(String datePart) {
return dateTruncFunctionSymbol;
}

@Override
public DBFunctionSymbol getDBMinutes() {
return minutesFunctionSymbol;
Expand Down Expand Up @@ -1374,6 +1439,51 @@ protected DBFunctionSymbol createMinutesFunctionSymbol() {
this::serializeMinutes);
}

protected DBFunctionSymbol createWeekFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_WEEK", rootDBType, dbIntegerType, false,
this::serializeWeek);
}

protected DBFunctionSymbol createQuarterFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_QUARTER", rootDBType, dbIntegerType, false,
this::serializeQuarter);
}

protected DBFunctionSymbol createDecadeFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_DECADE", rootDBType, dbIntegerType, false,
this::serializeDecade);
}

protected DBFunctionSymbol createCenturyFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_CENTURY", rootDBType, dbIntegerType, false,
this::serializeCentury);
}

protected DBFunctionSymbol createMillenniumFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_MILLENNIUM", rootDBType, dbIntegerType, false,
this::serializeMillennium);
}

protected DBFunctionSymbol createMillisecondsFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_MILLISECONDS", rootDBType, dbDecimalType, false,
this::serializeMilliseconds);
}

protected DBFunctionSymbol createMicrosecondsFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_MICROSECONDS", rootDBType, dbIntegerType, false,
this::serializeMicroseconds);
}

protected DBFunctionSymbol createDateTruncFunctionSymbol() {
return new DBFunctionSymbolWithSerializerImpl("DB_DATE_TRUNC", ImmutableList.of(dbStringType, dbDateType), dbDateType, false,
this::serializeDateTrunc) {
@Override
protected boolean mayReturnNullWithoutNullArguments() {
return false;
}
};
}

protected DBFunctionSymbol createSecondsFunctionSymbol() {
return new UnaryDBFunctionSymbolWithSerializerImpl("DB_SECONDS", rootDBType, dbDecimalType, false,
this::serializeSeconds);
Expand Down Expand Up @@ -1553,6 +1663,38 @@ protected abstract String serializeSeconds(ImmutableList<? extends ImmutableTerm
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeWeek(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeQuarter(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeDecade(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeCentury(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeMillennium(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeMilliseconds(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeMicroseconds(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeDateTrunc(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);

protected abstract String serializeTz(ImmutableList<? extends ImmutableTerm> terms,
Function<ImmutableTerm, String> termConverter,
TermFactory termFactory);
Expand Down
Expand Up @@ -8,9 +8,9 @@

import java.util.function.Function;

public class SQLServerDBIsTrueFunctionSymbolImpl extends DefaultDBIsTrueFunctionSymbol {
public class EqualsTrueDBIsTrueFunctionSymbolImpl extends DefaultDBIsTrueFunctionSymbol {

protected SQLServerDBIsTrueFunctionSymbolImpl(DBTermType dbBooleanTermType) {
protected EqualsTrueDBIsTrueFunctionSymbolImpl(DBTermType dbBooleanTermType) {
super(dbBooleanTermType);
}

Expand Down
Expand Up @@ -390,6 +390,46 @@ protected String serializeSeconds(ImmutableList<? extends ImmutableTerm> terms,
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeWeek(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeQuarter(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeDecade(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeCentury(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeMillennium(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeMilliseconds(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeMicroseconds(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeDateTrunc(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}

@Override
protected String serializeTz(ImmutableList<? extends ImmutableTerm> terms, Function<ImmutableTerm, String> termConverter, TermFactory termFactory) {
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
Expand Down Expand Up @@ -913,4 +953,6 @@ protected String serializeCheckAndConvertDateFromString(ImmutableList<? extends
throw new UnsupportedOperationException("Operation not supported by the MockupDBFunctionSymbolFactory");
}



}
@@ -0,0 +1,101 @@
package it.unibz.inf.ontop.model.term.functionsymbol.impl;

import com.google.common.collect.ImmutableList;
import it.unibz.inf.ontop.iq.node.VariableNullability;
import it.unibz.inf.ontop.model.term.*;
import it.unibz.inf.ontop.model.term.functionsymbol.RDFTermFunctionSymbol;
import it.unibz.inf.ontop.model.term.functionsymbol.db.DBFunctionSymbol;
import it.unibz.inf.ontop.model.term.functionsymbol.impl.ofn.OfnMultitypedInputBinarySPARQLFunctionSymbolImpl;
import it.unibz.inf.ontop.model.term.impl.RDFTermTypeConstantImpl;
import it.unibz.inf.ontop.model.type.DBTermType;
import it.unibz.inf.ontop.model.type.DBTypeFactory;
import it.unibz.inf.ontop.model.type.RDFTermType;
import it.unibz.inf.ontop.model.type.TermTypeInference;
import it.unibz.inf.ontop.model.vocabulary.Ontop;
import org.apache.commons.rdf.api.IRI;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;

public class DateTruncSPARQLFunctionSymbolImpl extends ReduciblePositiveAritySPARQLFunctionSymbolImpl {

private final static String[] supportedDateParts = new String[] {
"microsecond",
"millisecond",
"microseconds",
"milliseconds",
"second",
"minute",
"hour",
"day",
"week",
"month",
"quarter",
"year",
"decade",
"century",
"millennium"
};

private final Function<String, DBFunctionSymbol> dbFunctionSymbolFunction;
private final RDFTermType targetType;


public DateTruncSPARQLFunctionSymbolImpl(@Nonnull RDFTermType inputDateType,
@Nonnull RDFTermType inputSecondType,
@Nonnull Function<String, DBFunctionSymbol> dbFunctionSymbolFunction) {
super("SP_DATE_TRUNC", Ontop.DATE_TRUNC, ImmutableList.of(inputDateType, inputSecondType));
this.targetType = inputDateType;
this.dbFunctionSymbolFunction = dbFunctionSymbolFunction;
}

@Override
protected ImmutableTerm computeLexicalTerm(ImmutableList<ImmutableTerm> subLexicalTerms,
ImmutableList<ImmutableTerm> typeTerms, TermFactory termFactory,
ImmutableTerm returnedTypeTerm) {
if(!(subLexicalTerms.get(1) instanceof Constant)) {
//TODO - create more specialized exception to throw here.
throw new RuntimeException("Only constants are supported as Date-Part parameter.");
}
var constant = (Constant)subLexicalTerms.get(1);
var value = constant.getValue();
if(!Arrays.stream(supportedDateParts)
.anyMatch(part -> part.equalsIgnoreCase(value))) {
//TODO - create more specialized exception to throw here.
throw new RuntimeException(String.format("Date-Part %s is not supported.", value));
}

return termFactory.getConversion2RDFLexical(
termFactory.getImmutableFunctionalTerm(
dbFunctionSymbolFunction.apply(value),
termFactory.getConversionFromRDFLexical2DB(targetType.getClosestDBType(termFactory.getTypeFactory().getDBTypeFactory()), subLexicalTerms.get(0), targetType),
subLexicalTerms.get(1)
), targetType);
}

@Override
protected ImmutableTerm computeTypeTerm(ImmutableList<? extends ImmutableTerm> subLexicalTerms,
ImmutableList<ImmutableTerm> typeTerms, TermFactory termFactory,
VariableNullability variableNullability) {
return termFactory.getRDFTermTypeConstant(targetType);
}

@Override
public boolean isAlwaysInjectiveInTheAbsenceOfNonInjectiveFunctionalTerms() {
return false;
}

@Override
public Optional<TermTypeInference> inferType(ImmutableList<? extends ImmutableTerm> terms) {
return Optional.of(TermTypeInference.declareTermType(targetType));
}

@Override
public boolean canBePostProcessed(ImmutableList<? extends ImmutableTerm> arguments) {
return false;
}
}