Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Derive output column names #3812

Closed
xxchan opened this issue Jul 12, 2022 · 2 comments · Fixed by #7172
Closed

frontend: Derive output column names #3812

xxchan opened this issue Jul 12, 2022 · 2 comments · Fixed by #7172

Comments

@xxchan
Copy link
Member

xxchan commented Jul 12, 2022

In PG

postgres=# select abs(1);
 abs
-----
   1
(1 row)

postgres=# select count(1);
 count
-------
     1
(1 row)

In risingwave

dev=> select abs(1);
 ?column?
----------
        1
(1 row)

dev=> select count(1);
 ?column?
----------
        1
(1 row)

related but seems different: #3690

@xiangjinwu
Copy link
Contributor

To clarify the difference from #3690: the field names mentioned in that issue is internal, while the output column name shown in this issue is part of SQL semantic. For historical context on how they were decoupled and derived independently, check #2465 and #1433

@xiangjinwu xiangjinwu changed the title frontend: Derive function name frontend: Derive output column names Sep 27, 2022
@xiangjinwu
Copy link
Contributor

This affects the result comparison in regress tests (e.g. #5452)

PostgreSQL:
https://github.com/postgres/postgres/blob/86a4dc1e6f29d1992a2afa3fac1a0b0a6e84568c/src/backend/parser/parse_target.c#L1729

RisingWave:

SelectItem::UnnamedExpr(expr) => {
let (select_expr, alias) = match &expr.clone() {
Expr::Identifier(ident) => {
(self.bind_expr(expr)?, Some(ident.real_value()))
}
Expr::CompoundIdentifier(idents) => (
self.bind_expr(expr)?,
idents.last().map(|ident| ident.real_value()),
),
Expr::FieldIdentifier(field_expr, idents) => (
self.bind_single_field_column(*field_expr.clone(), idents)?,
idents.last().map(|ident| ident.real_value()),
),
_ => (self.bind_expr(expr)?, None),
};
select_list.push(select_expr);
aliases.push(alias);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants