|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql.SqlNode org.eigenbase.sql.SqlIntervalQualifier
public class SqlIntervalQualifier
Represents an INTERVAL qualifier.
INTERVAL qualifier is defined as follows:
<interval qualifier> ::=
<start field> TO <end field>
| <single datetime field>
<start field> ::=
<non-second primary datetime field>
[ <left paren> <interval leading field precision>
<right paren> ]
<end field> ::=
<non-second primary datetime field>
| SECOND [ <left paren>
<interval fractional seconds precision> <right paren> ]
<single datetime field> ::=
<non-second primary datetime field>
[ <left paren> <interval leading field precision>
<right paren> ]
| SECOND [ <left paren>
<interval leading field precision>
[ <comma> <interval fractional seconds precision> ]
<right paren> ]
<primary datetime field> ::=
<non-second primary datetime field>
| SECOND
<non-second primary datetime field> ::= YEAR | MONTH | DAY | HOUR
| MINUTE
<interval fractional seconds precision> ::=
<unsigned integer>
<interval leading field precision> ::= <unsigned integer>
Examples include:
INTERVAL '1:23:45.678' HOUR TO SECOND
INTERVAL '1 2:3:4' DAY TO SECOND
INTERVAL '1 2:3:4' DAY(4) TO SECOND(4)
Nested Class Summary | |
---|---|
static class |
SqlIntervalQualifier.TimeUnit
Enumeration of time units used to construct an interval. |
Field Summary | |
---|---|
private SqlIntervalQualifier.TimeUnit |
endUnit
|
private int |
fractionalSecondPrecision
|
private int |
startPrecision
|
private SqlIntervalQualifier.TimeUnit |
startUnit
|
private static int |
USE_DEFAULT_PRECISION
|
private boolean |
useDefaultFractionalSecondPrecision
|
private boolean |
useDefaultStartPrecision
|
Fields inherited from class org.eigenbase.sql.SqlNode |
---|
emptyArray |
Constructor Summary | |
---|---|
SqlIntervalQualifier(SqlIntervalQualifier.TimeUnit startUnit,
int startPrecision,
SqlIntervalQualifier.TimeUnit endUnit,
int fractionalSecondPrecision,
SqlParserPos pos)
|
|
SqlIntervalQualifier(SqlIntervalQualifier.TimeUnit startUnit,
SqlIntervalQualifier.TimeUnit endUnit,
SqlParserPos pos)
|
Method Summary | ||
---|---|---|
|
accept(SqlVisitor<R> visitor)
Accepts a generic visitor. |
|
SqlNode |
clone(SqlParserPos pos)
Clones a SqlNode with a different position. |
|
static int |
combineFractionalSecondPrecisionPreservingDefault(SqlIntervalQualifier qual1,
SqlIntervalQualifier qual2)
|
|
static int |
combineStartPrecisionPreservingDefault(SqlIntervalQualifier qual1,
SqlIntervalQualifier qual2)
|
|
boolean |
equalsDeep(SqlNode node,
boolean fail)
Returns whether this node is structurally equivalent to another node. |
|
int[] |
evaluateIntervalLiteral(String value)
Validates an INTERVAL literal according to the rules specified by the interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsDay(int sign,
String value)
Validates an INTERVAL literal against a DAY interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsDayToHour(int sign,
String value)
Validates an INTERVAL literal against a DAY TO HOUR interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsDayToMinute(int sign,
String value)
Validates an INTERVAL literal against a DAY TO MINUTE interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsDayToSecond(int sign,
String value)
Validates an INTERVAL literal against a DAY TO SECOND interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsHour(int sign,
String value)
Validates an INTERVAL literal against an HOUR interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsHourToMinute(int sign,
String value)
Validates an INTERVAL literal against an HOUR TO MINUTE interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsHourToSecond(int sign,
String value)
Validates an INTERVAL literal against an HOUR TO SECOND interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsMinute(int sign,
String value)
Validates an INTERVAL literal against an MINUTE interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsMinuteToSecond(int sign,
String value)
Validates an INTERVAL literal against an MINUTE TO SECOND interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsMonth(int sign,
String value)
Validates an INTERVAL literal against a MONTH interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsSecond(int sign,
String value)
Validates an INTERVAL literal against an SECOND interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsYear(int sign,
String value)
Validates an INTERVAL literal against a YEAR interval qualifier. |
|
private int[] |
evaluateIntervalLiteralAsYearToMonth(int sign,
String value)
Validates an INTERVAL literal against a YEAR TO MONTH interval qualifier. |
|
private int[] |
fillIntervalValueArray(int sign,
int year,
int month)
|
|
private int[] |
fillIntervalValueArray(int sign,
int day,
int hour,
int minute,
int second,
int secondFrac)
|
|
static long |
getConversion(SqlIntervalQualifier.TimeUnit unit)
|
|
static int |
getDefaultPrecisionId()
|
|
SqlIntervalQualifier.TimeUnit |
getEndUnit()
|
|
int |
getFractionalSecondPrecision()
|
|
int |
getFractionalSecondPrecisionPreservingDefault()
|
|
private int |
getIntervalSign(String value)
|
|
int |
getStartPrecision()
|
|
int |
getStartPrecisionPreservingDefault()
|
|
SqlIntervalQualifier.TimeUnit |
getStartUnit()
|
|
private boolean |
isFractionalSecondFieldInRange(int field)
|
|
private boolean |
isLeadFieldInRange(int field,
SqlIntervalQualifier.TimeUnit unit)
|
|
private boolean |
isSecondaryFieldInRange(int field,
SqlIntervalQualifier.TimeUnit unit)
|
|
boolean |
isYearMonth()
|
|
private int |
normalizeSecondFraction(String secondFracStr)
|
|
private String |
stripLeadingSign(String value)
|
|
void |
unparse(SqlWriter writer,
int leftPrec,
int rightPrec)
Writes a SQL representation of this node to a writer. |
|
void |
validate(SqlValidator validator,
SqlValidatorScope scope)
Validates this node. |
Methods inherited from class org.eigenbase.sql.SqlNode |
---|
clone, cloneArray, equalDeep, findValidOptions, getKind, getMonotonicity, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int USE_DEFAULT_PRECISION
private final int startPrecision
private final SqlIntervalQualifier.TimeUnit startUnit
private final SqlIntervalQualifier.TimeUnit endUnit
private final int fractionalSecondPrecision
private final boolean useDefaultStartPrecision
private final boolean useDefaultFractionalSecondPrecision
Constructor Detail |
---|
public SqlIntervalQualifier(SqlIntervalQualifier.TimeUnit startUnit, int startPrecision, SqlIntervalQualifier.TimeUnit endUnit, int fractionalSecondPrecision, SqlParserPos pos)
public SqlIntervalQualifier(SqlIntervalQualifier.TimeUnit startUnit, SqlIntervalQualifier.TimeUnit endUnit, SqlParserPos pos)
Method Detail |
---|
public void validate(SqlValidator validator, SqlValidatorScope scope)
SqlNode
The typical implementation of this method will make a callback to the
validator appropriate to the node type and context. The validator has
methods such as SqlValidator.validateLiteral(org.eigenbase.sql.SqlLiteral)
for these purposes.
validate
in class SqlNode
scope
- Validatorpublic <R> R accept(SqlVisitor<R> visitor)
SqlNode
Implementations of this method in subtypes simply call the appropriate
visit
method on the visitor object
.
The type parameter R
must be consistent with the type
parameter of the visitor.
accept
in class SqlNode
public boolean equalsDeep(SqlNode node, boolean fail)
SqlNode
equalsDeep
in class SqlNode
public static int getDefaultPrecisionId()
public int getStartPrecision()
public int getStartPrecisionPreservingDefault()
public static int combineStartPrecisionPreservingDefault(SqlIntervalQualifier qual1, SqlIntervalQualifier qual2)
public int getFractionalSecondPrecision()
public int getFractionalSecondPrecisionPreservingDefault()
public static int combineFractionalSecondPrecisionPreservingDefault(SqlIntervalQualifier qual1, SqlIntervalQualifier qual2)
public SqlIntervalQualifier.TimeUnit getStartUnit()
public SqlIntervalQualifier.TimeUnit getEndUnit()
public SqlNode clone(SqlParserPos pos)
SqlNode
clone
in class SqlNode
public void unparse(SqlWriter writer, int leftPrec, int rightPrec)
SqlNode
The leftPrec
and rightPrec
parameters give
us enough context to decide whether we need to enclose the expression in
parentheses. For example, we need parentheses around "2 + 3" if preceded
by "5 *". This is because the precedence of the "*" operator is greater
than the precedence of the "+" operator.
The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.
If SqlWriter.isAlwaysUseParentheses()
is true, we use
parentheses even when they are not required by the precedence rules.
For the details of this algorithm, see SqlCall.unparse(org.eigenbase.sql.SqlWriter, int, int)
.
unparse
in class SqlNode
writer
- Target writerleftPrec
- The precedence of the SqlNode
immediately
preceding this node in a depth-first scan of the parse treerightPrec
- The precedence of the SqlNode
immediatelypublic boolean isYearMonth()
private int getIntervalSign(String value)
private String stripLeadingSign(String value)
private boolean isLeadFieldInRange(int field, SqlIntervalQualifier.TimeUnit unit)
private boolean isFractionalSecondFieldInRange(int field)
private boolean isSecondaryFieldInRange(int field, SqlIntervalQualifier.TimeUnit unit)
private int normalizeSecondFraction(String secondFracStr)
private int[] fillIntervalValueArray(int sign, int year, int month)
private int[] fillIntervalValueArray(int sign, int day, int hour, int minute, int second, int secondFrac)
private int[] evaluateIntervalLiteralAsYear(int sign, String value)
private int[] evaluateIntervalLiteralAsYearToMonth(int sign, String value)
private int[] evaluateIntervalLiteralAsMonth(int sign, String value)
private int[] evaluateIntervalLiteralAsDay(int sign, String value)
private int[] evaluateIntervalLiteralAsDayToHour(int sign, String value)
private int[] evaluateIntervalLiteralAsDayToMinute(int sign, String value)
private int[] evaluateIntervalLiteralAsDayToSecond(int sign, String value)
private int[] evaluateIntervalLiteralAsHour(int sign, String value)
private int[] evaluateIntervalLiteralAsHourToMinute(int sign, String value)
private int[] evaluateIntervalLiteralAsHourToSecond(int sign, String value)
private int[] evaluateIntervalLiteralAsMinute(int sign, String value)
private int[] evaluateIntervalLiteralAsMinuteToSecond(int sign, String value)
private int[] evaluateIntervalLiteralAsSecond(int sign, String value)
public int[] evaluateIntervalLiteral(String value)
public static long getConversion(SqlIntervalQualifier.TimeUnit unit)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |