Unverified 提交 cf2d49c5 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1598 from katzyn/misc

Minor changes in parser and documentation
...@@ -3418,7 +3418,7 @@ INTERVAL MINUTE TO SECOND ...@@ -3418,7 +3418,7 @@ INTERVAL MINUTE TO SECOND
" "
"Functions (Aggregate)","AVG"," "Functions (Aggregate)","AVG","
AVG ( [ DISTINCT ] { numeric } ) AVG ( [ DISTINCT|ALL ] { numeric } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The average (mean) value. The average (mean) value.
...@@ -3474,7 +3474,7 @@ ANY(NAME LIKE 'W%') ...@@ -3474,7 +3474,7 @@ ANY(NAME LIKE 'W%')
" "
"Functions (Aggregate)","COUNT"," "Functions (Aggregate)","COUNT","
COUNT( { * | { [ DISTINCT ] expression } } ) COUNT( { * | { [ DISTINCT|ALL ] expression } } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The count of all row, or of the non-null values. The count of all row, or of the non-null values.
...@@ -3486,7 +3486,7 @@ COUNT(*) ...@@ -3486,7 +3486,7 @@ COUNT(*)
" "
"Functions (Aggregate)","GROUP_CONCAT"," "Functions (Aggregate)","GROUP_CONCAT","
GROUP_CONCAT ( [ DISTINCT ] string GROUP_CONCAT ( [ DISTINCT|ALL ] string
[ ORDER BY { expression [ ASC | DESC ] } [,...] ] [ ORDER BY { expression [ ASC | DESC ] } [,...] ]
[ SEPARATOR expression ] ) [ SEPARATOR expression ] )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
...@@ -3501,7 +3501,7 @@ GROUP_CONCAT(NAME ORDER BY ID SEPARATOR ', ') ...@@ -3501,7 +3501,7 @@ GROUP_CONCAT(NAME ORDER BY ID SEPARATOR ', ')
" "
"Functions (Aggregate)","ARRAY_AGG"," "Functions (Aggregate)","ARRAY_AGG","
ARRAY_AGG ( [ DISTINCT ] string ARRAY_AGG ( [ DISTINCT|ALL ] string
[ ORDER BY { expression [ ASC | DESC ] } [,...] ] ) [ ORDER BY { expression [ ASC | DESC ] } [,...] ] )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
...@@ -3538,7 +3538,7 @@ MIN(NAME) ...@@ -3538,7 +3538,7 @@ MIN(NAME)
" "
"Functions (Aggregate)","SUM"," "Functions (Aggregate)","SUM","
SUM( [ DISTINCT ] { numeric } ) SUM( [ DISTINCT|ALL ] { numeric } )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The sum of all values. The sum of all values.
...@@ -3564,7 +3564,7 @@ SELECT SELECTIVITY(FIRSTNAME), SELECTIVITY(NAME) FROM TEST WHERE ROWNUM()<20000 ...@@ -3564,7 +3564,7 @@ SELECT SELECTIVITY(FIRSTNAME), SELECTIVITY(NAME) FROM TEST WHERE ROWNUM()<20000
" "
"Functions (Aggregate)","STDDEV_POP"," "Functions (Aggregate)","STDDEV_POP","
STDDEV_POP( [ DISTINCT ] numeric ) STDDEV_POP( [ DISTINCT|ALL ] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The population standard deviation. The population standard deviation.
...@@ -3576,7 +3576,7 @@ STDDEV_POP(X) ...@@ -3576,7 +3576,7 @@ STDDEV_POP(X)
" "
"Functions (Aggregate)","STDDEV_SAMP"," "Functions (Aggregate)","STDDEV_SAMP","
STDDEV_SAMP( [ DISTINCT ] numeric ) STDDEV_SAMP( [ DISTINCT|ALL ] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The sample standard deviation. The sample standard deviation.
...@@ -3588,7 +3588,7 @@ STDDEV(X) ...@@ -3588,7 +3588,7 @@ STDDEV(X)
" "
"Functions (Aggregate)","VAR_POP"," "Functions (Aggregate)","VAR_POP","
VAR_POP( [ DISTINCT ] numeric ) VAR_POP( [ DISTINCT|ALL ] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The population variance (square of the population standard deviation). The population variance (square of the population standard deviation).
...@@ -3600,7 +3600,7 @@ VAR_POP(X) ...@@ -3600,7 +3600,7 @@ VAR_POP(X)
" "
"Functions (Aggregate)","VAR_SAMP"," "Functions (Aggregate)","VAR_SAMP","
VAR_SAMP( [ DISTINCT ] numeric ) VAR_SAMP( [ DISTINCT|ALL ] numeric )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The sample variance (square of the sample standard deviation). The sample variance (square of the sample standard deviation).
...@@ -3612,7 +3612,7 @@ VAR_SAMP(X) ...@@ -3612,7 +3612,7 @@ VAR_SAMP(X)
" "
"Functions (Aggregate)","MEDIAN"," "Functions (Aggregate)","MEDIAN","
MEDIAN( [ DISTINCT ] value ) MEDIAN( [ DISTINCT|ALL ] value )
[FILTER (WHERE expression)] [OVER windowNameOrSpecification] [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
"," ","
The value separating the higher half of a values from the lower half. The value separating the higher half of a values from the lower half.
...@@ -3672,7 +3672,8 @@ ABS(-2147483648) should be 2147483648, but this value is not allowed for this da ...@@ -3672,7 +3672,8 @@ ABS(-2147483648) should be 2147483648, but this value is not allowed for this da
It leads to an exception. It leads to an exception.
To avoid it cast argument of this function to a higher data type. To avoid it cast argument of this function to a higher data type.
"," ","
ABS(ID) ABS(VALUE)
ABS(CAST(VALUE AS BIGINT))
" "
"Functions (Numeric)","ACOS"," "Functions (Numeric)","ACOS","
...@@ -4599,7 +4600,7 @@ DAYNAME(CREATED) ...@@ -4599,7 +4600,7 @@ DAYNAME(CREATED)
" "
"Functions (Time and Date)","DAY_OF_MONTH"," "Functions (Time and Date)","DAY_OF_MONTH","
DAY_OF_MONTH(dateAndTime) DAY_OF_MONTH(dateAndTime|interval)
"," ","
Returns the day of the month (1-31). Returns the day of the month (1-31).
"," ","
...@@ -4623,7 +4624,7 @@ ISO_DAY_OF_WEEK(CREATED) ...@@ -4623,7 +4624,7 @@ ISO_DAY_OF_WEEK(CREATED)
" "
"Functions (Time and Date)","DAY_OF_YEAR"," "Functions (Time and Date)","DAY_OF_YEAR","
DAY_OF_YEAR(dateAndTime) DAY_OF_YEAR(dateAndTime|interval)
"," ","
Returns the day of the year (1-366). Returns the day of the year (1-366).
"," ","
...@@ -4657,7 +4658,7 @@ CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', ...@@ -4657,7 +4658,7 @@ CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06',
" "
"Functions (Time and Date)","HOUR"," "Functions (Time and Date)","HOUR","
HOUR(dateAndTime) HOUR(dateAndTime|interval)
"," ","
Returns the hour (0-23) from a date/time value. Returns the hour (0-23) from a date/time value.
"," ","
...@@ -4665,7 +4666,7 @@ HOUR(CREATED) ...@@ -4665,7 +4666,7 @@ HOUR(CREATED)
" "
"Functions (Time and Date)","MINUTE"," "Functions (Time and Date)","MINUTE","
MINUTE(dateAndTime) MINUTE(dateAndTime|interval)
"," ","
Returns the minute (0-59) from a date/time value. Returns the minute (0-59) from a date/time value.
"," ","
...@@ -4673,7 +4674,7 @@ MINUTE(CREATED) ...@@ -4673,7 +4674,7 @@ MINUTE(CREATED)
" "
"Functions (Time and Date)","MONTH"," "Functions (Time and Date)","MONTH","
MONTH(dateAndTime) MONTH(dateAndTime|interval)
"," ","
Returns the month (1-12) from a date/time value. Returns the month (1-12) from a date/time value.
"," ","
...@@ -4714,7 +4715,7 @@ SECOND(dateAndTime) ...@@ -4714,7 +4715,7 @@ SECOND(dateAndTime)
"," ","
Returns the second (0-59) from a date/time value. Returns the second (0-59) from a date/time value.
"," ","
SECOND(CREATED) SECOND(CREATED|interval)
" "
"Functions (Time and Date)","WEEK"," "Functions (Time and Date)","WEEK","
...@@ -4738,7 +4739,7 @@ ISO_WEEK(CREATED) ...@@ -4738,7 +4739,7 @@ ISO_WEEK(CREATED)
" "
"Functions (Time and Date)","YEAR"," "Functions (Time and Date)","YEAR","
YEAR(dateAndTime) YEAR(dateAndTime|interval)
"," ","
Returns the year from a date/time value. Returns the year from a date/time value.
"," ","
...@@ -4756,10 +4757,10 @@ ISO_YEAR(CREATED) ...@@ -4756,10 +4757,10 @@ ISO_YEAR(CREATED)
"Functions (System)","ARRAY_GET"," "Functions (System)","ARRAY_GET","
ARRAY_GET(arrayExpression, indexExpression) ARRAY_GET(arrayExpression, indexExpression)
"," ","
Returns one element of an array. Returns element at the specified 1-based index from an array.
Returns NULL if there is no such element or array is NULL. Returns NULL if there is no such element or array is NULL.
"," ","
CALL ARRAY_GET(('Hello', 'World'), 2) CALL ARRAY_GET(ARRAY['Hello', 'World'], 2)
" "
"Functions (System)","ARRAY_LENGTH"," "Functions (System)","ARRAY_LENGTH","
...@@ -4768,7 +4769,7 @@ ARRAY_LENGTH(arrayExpression) ...@@ -4768,7 +4769,7 @@ ARRAY_LENGTH(arrayExpression)
Returns the length of an array. Returns the length of an array.
Returns NULL if the specified array is NULL. Returns NULL if the specified array is NULL.
"," ","
CALL ARRAY_LENGTH(('Hello', 'World')) CALL ARRAY_LENGTH(ARRAY['Hello', 'World'])
" "
"Functions (System)","ARRAY_CONTAINS"," "Functions (System)","ARRAY_CONTAINS","
...@@ -4777,7 +4778,7 @@ ARRAY_CONTAINS(arrayExpression, value) ...@@ -4777,7 +4778,7 @@ ARRAY_CONTAINS(arrayExpression, value)
Returns a boolean TRUE if the array contains the value or FALSE if it does not contain it. Returns a boolean TRUE if the array contains the value or FALSE if it does not contain it.
Returns NULL if the specified array is NULL. Returns NULL if the specified array is NULL.
"," ","
CALL ARRAY_CONTAINS(('Hello', 'World'), 'Hello') CALL ARRAY_CONTAINS(ARRAY['Hello', 'World'], 'Hello')
" "
"Functions (System)","AUTOCOMMIT"," "Functions (System)","AUTOCOMMIT","
......
...@@ -116,7 +116,7 @@ build jarClient ...@@ -116,7 +116,7 @@ build jarClient
<h3>Using Apache Lucene</h3> <h3>Using Apache Lucene</h3>
<p> <p>
Apache Lucene 5.5.5 is used for testing. Apache Lucene 5.5.5 is used for testing.
Newer versions up to 7.5.0 can also be used. Newer versions up to 7.6.0 can also be used.
</p> </p>
<h2 id="maven2">Using Maven 2</h2> <h2 id="maven2">Using Maven 2</h2>
......
...@@ -1234,7 +1234,7 @@ org.h2.fulltext.FullText.searchData(conn, text, limit, offset); ...@@ -1234,7 +1234,7 @@ org.h2.fulltext.FullText.searchData(conn, text, limit, offset);
<h3>Using the Apache Lucene Fulltext Search</h3> <h3>Using the Apache Lucene Fulltext Search</h3>
<p> <p>
To use the Apache Lucene full text search, you need the Lucene library in the classpath. To use the Apache Lucene full text search, you need the Lucene library in the classpath.
Apache Lucene 5.5.5 or later version up to 7.5.0 is required. Apache Lucene 5.5.5 or later version up to 7.6.0 is required.
Newer versions may also work, but were not tested. Newer versions may also work, but were not tested.
How to do that depends on the application; if you use the H2 Console, you can add the Lucene How to do that depends on the application; if you use the H2 Console, you can add the Lucene
jar file to the environment variables <code>H2DRIVERS</code> or jar file to the environment variables <code>H2DRIVERS</code> or
......
...@@ -2949,7 +2949,7 @@ public class Parser { ...@@ -2949,7 +2949,7 @@ public class Parser {
if (readIf(ASTERISK)) { if (readIf(ASTERISK)) {
r = new Aggregate(AggregateType.COUNT_ALL, null, currentSelect, false); r = new Aggregate(AggregateType.COUNT_ALL, null, currentSelect, false);
} else { } else {
boolean distinct = readIf(DISTINCT); boolean distinct = readDistinctAgg();
Expression on = readExpression(); Expression on = readExpression();
if (on instanceof Wildcard && !distinct) { if (on instanceof Wildcard && !distinct) {
// PostgreSQL compatibility: count(t.*) // PostgreSQL compatibility: count(t.*)
...@@ -2960,7 +2960,7 @@ public class Parser { ...@@ -2960,7 +2960,7 @@ public class Parser {
} }
break; break;
case GROUP_CONCAT: { case GROUP_CONCAT: {
boolean distinct = readIf(DISTINCT); boolean distinct = readDistinctAgg();
if (equalsToken("GROUP_CONCAT", aggregateName)) { if (equalsToken("GROUP_CONCAT", aggregateName)) {
r = new Aggregate(AggregateType.GROUP_CONCAT, readExpression(), currentSelect, distinct); r = new Aggregate(AggregateType.GROUP_CONCAT, readExpression(), currentSelect, distinct);
if (readIf(ORDER)) { if (readIf(ORDER)) {
...@@ -2985,7 +2985,7 @@ public class Parser { ...@@ -2985,7 +2985,7 @@ public class Parser {
break; break;
} }
case ARRAY_AGG: { case ARRAY_AGG: {
boolean distinct = readIf(DISTINCT); boolean distinct = readDistinctAgg();
r = new Aggregate(AggregateType.ARRAY_AGG, readExpression(), currentSelect, distinct); r = new Aggregate(AggregateType.ARRAY_AGG, readExpression(), currentSelect, distinct);
if (readIf(ORDER)) { if (readIf(ORDER)) {
read("BY"); read("BY");
...@@ -3020,7 +3020,7 @@ public class Parser { ...@@ -3020,7 +3020,7 @@ public class Parser {
break; break;
} }
default: default:
boolean distinct = readIf(DISTINCT); boolean distinct = readDistinctAgg();
r = new Aggregate(aggregateType, readExpression(), currentSelect, distinct); r = new Aggregate(aggregateType, readExpression(), currentSelect, distinct);
break; break;
} }
...@@ -3078,7 +3078,7 @@ public class Parser { ...@@ -3078,7 +3078,7 @@ public class Parser {
} }
private JavaAggregate readJavaAggregate(UserAggregate aggregate) { private JavaAggregate readJavaAggregate(UserAggregate aggregate) {
boolean distinct = readIf(DISTINCT); boolean distinct = readDistinctAgg();
ArrayList<Expression> params = Utils.newSmallArrayList(); ArrayList<Expression> params = Utils.newSmallArrayList();
do { do {
params.add(readExpression()); params.add(readExpression());
...@@ -3089,6 +3089,14 @@ public class Parser { ...@@ -3089,6 +3089,14 @@ public class Parser {
return agg; return agg;
} }
private boolean readDistinctAgg() {
if (readIf(DISTINCT)) {
return true;
}
readIf(ALL);
return false;
}
private void readFilterAndOver(AbstractAggregate aggregate) { private void readFilterAndOver(AbstractAggregate aggregate) {
if (readIf("FILTER")) { if (readIf("FILTER")) {
read(OPEN_PAREN); read(OPEN_PAREN);
......
...@@ -642,7 +642,6 @@ public final class DateTimeFunctions { ...@@ -642,7 +642,6 @@ public final class DateTimeFunctions {
v = IntervalUtils.monthsFromInterval(qualifier, negative, leading, remaining); v = IntervalUtils.monthsFromInterval(qualifier, negative, leading, remaining);
break; break;
case DAY_OF_MONTH: case DAY_OF_MONTH:
case DAY_OF_WEEK:
case DAY_OF_YEAR: case DAY_OF_YEAR:
v = IntervalUtils.daysFromInterval(qualifier, negative, leading, remaining); v = IntervalUtils.daysFromInterval(qualifier, negative, leading, remaining);
break; break;
......
...@@ -26,6 +26,15 @@ select sum(v), sum(v) filter (where v >= 4) from test where v <= 10; ...@@ -26,6 +26,15 @@ select sum(v), sum(v) filter (where v >= 4) from test where v <= 10;
> 55 49 > 55 49
> rows: 1 > rows: 1
insert into test values (1), (2), (8);
> update count: 3
select sum(v), sum(all v), sum(distinct v) from test;
> SUM(V) SUM(V) SUM(DISTINCT V)
> ------ ------ ---------------
> 89 89 78
> rows: 1
drop table test; drop table test;
> ok > ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论