You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/10/12 23:07:00 UTC
[jira] [Commented] (IMPALA-10356) Analyzed query in explain plan is not quite right for insert with values clause
[ https://issues.apache.org/jira/browse/IMPALA-10356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616726#comment-17616726 ]
ASF subversion and git services commented on IMPALA-10356:
----------------------------------------------------------
Commit 0bc562a0200f285fe3f526cf7e0ce88cc89e94e7 in impala's branch refs/heads/master from Daniel Becker
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=0bc562a02 ]
IMPALA-10356: Fix SetOperationStmt::toSql() for VALUES statement with
single value
If the query contains a VALUES clause with a single value, the 'analyzed
query' in the level 2 explain plan contains a UNION where both sides are
the value from the VALUES clause. For
INSERT INTO double_tbl VALUES (-0.43149576573887316);
we get
SELECT CAST(-0.43149576573887316 AS DECIMAL(17,17))
UNION
SELECT CAST(-0.43149576573887316 AS DECIMAL(17,17));
This is because of a bug in 'SetOperationStmt::toSql()'; 'ValuesStmt's
are implemented as special 'UnionStmt's, which derive from
'SetOperationStmt'. 'SetOperationStmt::toSql()' implicitly assumes that
there are at least 2 operands and always prints the first one and the
last one separately, even if they are the same.
Note that 'ValuesStmt' is the only 'SetOperationStmt' that may contain a
single operand - it is syntactically impossible in SQL to create other
'SetOperationStmt's with only one operand.
This patch modifies 'SetOperationStmt::toSql()' so that if there is only
one operand, only that operand is printed (so there is no reference to
the set operation in the resulting string). This change does not affect
how such queries are handled, only how the analyzed query is printed.
Testing:
- Extended AnalyzeStmtsTest.TestValuesStmt so it now also checks what
VALUES clauses with one and two operands are rewritten to during
analysis.
Change-Id: I952377ed14eba26e3774e7776eb81a95d1d8e76f
Reviewed-on: http://gerrit.cloudera.org:8080/19048
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Daniel Becker <da...@cloudera.com>
> Analyzed query in explain plan is not quite right for insert with values clause
> -------------------------------------------------------------------------------
>
> Key: IMPALA-10356
> URL: https://issues.apache.org/jira/browse/IMPALA-10356
> Project: IMPALA
> Issue Type: Bug
> Components: Frontend
> Affects Versions: Impala 4.0.0
> Reporter: Tim Armstrong
> Assignee: Daniel Becker
> Priority: Major
> Labels: newbie, ramp-up
>
> In impala-shell:
> {noformat}
> create table double_tbl (d double) stored as textfile;
> set explain_level=2;
> explain insert into double_tbl values (-0.43149576573887316);
> {noformat}
> {noformat}
> +----------------------------------------------------------------------------------+
> | Explain String |
> +----------------------------------------------------------------------------------+
> | Max Per-Host Resource Reservation: Memory=0B Threads=1 |
> | Per-Host Resource Estimates: Memory=10MB |
> | Codegen disabled by planner |
> | Analyzed query: SELECT CAST(-0.43149576573887316 AS DECIMAL(17,17)) UNION SELECT |
> | CAST(-0.43149576573887316 AS DECIMAL(17,17)) |
> | |
> | F00:PLAN FRAGMENT [UNPARTITIONED] hosts=1 instances=1 |
> | | Per-Host Resources: mem-estimate=8B mem-reservation=0B thread-reservation=1 |
> | WRITE TO HDFS [default.double_tbl, OVERWRITE=false] |
> | | partitions=1 |
> | | output exprs: CAST(-0.43149576573887316 AS DOUBLE) |
> | | mem-estimate=8B mem-reservation=0B thread-reservation=0 |
> | | |
> | 00:UNION |
> | constant-operands=1 |
> | mem-estimate=0B mem-reservation=0B thread-reservation=0 |
> | tuple-ids=0 row-size=8B cardinality=1 |
> | in pipelines: <none> |
> +----------------------------------------------------------------------------------+
> {noformat}
> The analyzed query does not make sense. We should investigate and fix it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org