Closed jordanlewis closed 9 months ago
I found that the following patch immediately delivers the functionality, without any other change:
diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y
index 64cec45f2e..438b25f390 100644
--- a/pkg/sql/parser/sql.y
+++ b/pkg/sql/parser/sql.y
@@ -1298,7 +1298,7 @@ func (u *sqlSymUnion) asTenantClause() tree.TenantID {
%type <*tree.Tuple> expr_tuple1_ambiguous expr_tuple_unambiguous
%type <tree.NameList> attrs
%type <[]string> session_var_parts
-%type <tree.SelectExprs> target_list
+%type <tree.SelectExprs> target_list opt_target_list
%type <tree.UpdateExprs> set_clause_list
%type <*tree.UpdateExpr> set_clause multiple_set_clause
%type <tree.ArraySubscripts> array_subscripts
@@ -10144,7 +10144,7 @@ simple_select:
// [ OFFSET <expr> [ ROW | ROWS ] ]
// %SeeAlso: WEBDOCS/select-clause.html
simple_select_clause:
- SELECT opt_all_clause target_list
+ SELECT opt_all_clause opt_target_list
from_clause opt_where_clause
group_clause having_clause window_clause
{
@@ -10183,10 +10183,9 @@ simple_select_clause:
Where: tree.NewWhere(tree.AstWhere, $5.expr()),
GroupBy: $6.groupBy(),
Having: tree.NewWhere(tree.AstHaving, $7.expr()),
Window: $8.window(),
}
}
-| SELECT error // SHOW HELP: SELECT
set_operation:
select_clause UNION all_or_distinct select_clause
@@ -13486,6 +13485,10 @@ opt_asymmetric:
ASYMMETRIC {}
| /* EMPTY */ {}
+opt_target_list:
+ target_list { $$.val = $1.selExprs() }
+| /* EMPTY */ { $$.val = tree.SelectExprs{} }
+
target_list:
target_elem
{
However, I am bummed out that it requires removing the SELECT error
branch, which removes both error handling and the CLI interactive help.
I wasn't able to find a way to keep the error
clause; I suspect (given the error with it is shift/reduce) there is something to do with a %prec
clause, but I couldn't find it.
Hi query team, this feature is also needed by Hasura Graphql Engine. They have a workaround already, but still curious do we have a timeline for supporting this?
Postgres allows this syntax to
SELECT
from a table with no projections.This is not supported by CockroachDB.
Jira issue: CRDB-16953