Skip to content

Commit

Permalink
rename some variable name & fix comment error
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhiwei committed Nov 29, 2019
1 parent 7d1a5bc commit 27692d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
19 changes: 10 additions & 9 deletions core/src/main/codegen/templates/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1728,8 +1728,8 @@ List<SqlNode> SelectList() :
SqlNode SelectItem() :
{
SqlNode e;
SqlIdentifier id;
final List<SqlNode> ids = new ArrayList();
SqlIdentifier columnAlias;
final List<SqlNode> columnAliases = new ArrayList();
final Span s = span();
}
{
Expand All @@ -1738,24 +1738,25 @@ SqlNode SelectItem() :
(
LOOKAHEAD(2) (
[ <AS> ]
id = SimpleIdentifier()
columnAlias = SimpleIdentifier()
{
e = SqlStdOperatorTable.AS.createCall(s.end(e), e, id);
e = SqlStdOperatorTable.AS.createCall(s.end(e), e, columnAlias);
}
)
|
(
<AS> <LPAREN>
id = SimpleIdentifier() {
ids.add(id);
columnAlias = SimpleIdentifier() {
columnAliases.add(columnAlias);
}
( <COMMA> id = SimpleIdentifier() { ids.add(id);} )*
( <COMMA> columnAlias = SimpleIdentifier() { columnAliases.add(columnAlias);} )*
<RPAREN> {
if (!this.conformance.allowSelectTableFunction()) {
throw SqlUtil.newContextException(getPos(),
RESOURCE.notAllowTableFunctionInSelect());
RESOURCE.notAllowTableFunctionInSelect());
}
e = SqlStdOperatorTable.AS.createCall(s.end(e), e, new SqlNodeList(ids, s.end(e)));
e = SqlStdOperatorTable.AS.createCall(s.end(e), e,
new SqlNodeList(columnAliases, s.end(e)));
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
*/
public static final String UPDATE_ANON_PREFIX = "SYS$ANON";

/**
* Prefix for table function.
*/
private static final String TABLE_FUNCTION_PREFIX = "_table_function_";

//~ Instance fields --------------------------------------------------------

private final SqlOperatorTable opTab;
Expand Down Expand Up @@ -299,7 +294,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
// Flag saying if we enable the implicit type coercion.
private boolean enableTypeCoercion;

// Maping the table function and the select node.
// Mapping the table function and the select node.
private final Map<SqlSelect, SqlBasicCall> selectTableFunctions =
new IdentityHashMap<>();
//~ Constructors -----------------------------------------------------------
Expand Down Expand Up @@ -4333,7 +4328,7 @@ private void handleTableFunctionInSelect(
}
aliases.addAll(aliasList);

String tableAlias = TABLE_FUNCTION_PREFIX + nextGeneratedId++;
String tableAlias = functionCall.getOperator().getName();
// Expand the table function alias
for (String alias : aliasList) {
SqlIdentifier id = new SqlIdentifier(Lists.newArrayList
Expand Down
4 changes: 2 additions & 2 deletions site/_docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ selectWithoutFrom:

projectItem:
expression [ [ AS ] columnAlias ]
| expression AS '(' columnAlias [, columnAlias ]* ')'
| expression AS '(' columnAlias [, columnAlias ]* ')'
| tableAlias . *

tableExpression:
Expand Down Expand Up @@ -300,7 +300,7 @@ the <em>n</em>th item in the SELECT clause.
In *query*, *count* and *start* may each be either an unsigned integer literal
or a dynamic parameter whose value is an integer.

In *projectItem*, *expression* followed by a *As* column alias list is only allowed in
In *projectItem*, *expression* followed by a *As* column alias list is only allowed in
certain [conformance levels] ({{ site.apiRoot }}/org/apache/calcite/sql/validate/SqlConformance.html#allowSelectTableFunction--);
in those same conformance levels, table function can be used in the select list.
An aggregate query is a query that contains a GROUP BY or a HAVING
Expand Down

0 comments on commit 27692d3

Please sign in to comment.