Skip to content

Commit

Permalink
Fix julianhyde/optiq#227, "Extend extract function to support DateTim…
Browse files Browse the repository at this point in the history
…e data types".
  • Loading branch information
mehant authored and julianhyde committed Apr 3, 2014
1 parent 76eed6b commit ad3fd47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SqlExtractFunction() {
SqlKind.OTHER_FUNCTION,
ReturnTypes.BIGINT_NULLABLE,
null,
OperandTypes.INTERVAL_SAME_SAME,
OperandTypes.INTERVALINTERVAL_INTERVALDATETIME,
SqlFunctionCategory.SYSTEM);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/eigenbase/sql/type/OperandTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ public boolean checkSingleOperandType(
public static final SqlSingleOperandTypeChecker INTERVAL_DATETIME =
family(SqlTypeFamily.DATETIME_INTERVAL, SqlTypeFamily.DATETIME);

public static final SqlSingleOperandTypeChecker
INTERVALINTERVAL_INTERVALDATETIME =
OperandTypes.or(INTERVAL_SAME_SAME, INTERVAL_DATETIME);

// TODO: datetime+interval checking missing
// TODO: interval+datetime checking missing
public static final SqlSingleOperandTypeChecker PLUS_OPERATOR =
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/eigenbase/test/SqlValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5800,6 +5800,7 @@ public void _testGroupExpressionEquivalenceParams() {
"extract(year from interval '1-2' year to month)",
"BIGINT NOT NULL");
checkExp("extract(minute from interval '1.1' second)");
checkExp("extract(year from DATE '2008-2-2')");

checkWholeExpFails(
"extract(minute from interval '11' month)",
Expand Down

0 comments on commit ad3fd47

Please sign in to comment.