You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Wail Y. Alkowaileet (Jira)" <ji...@apache.org> on 2022/11/17 21:31:00 UTC
[jira] [Updated] (ASTERIXDB-3087) Remove useless casts for union all
[ https://issues.apache.org/jira/browse/ASTERIXDB-3087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wail Y. Alkowaileet updated ASTERIXDB-3087:
-------------------------------------------
Description:
DDL:
{code:java}
DROP DATAVERSE TinySocial IF EXISTS;
CREATE DATAVERSE TinySocial;USE TinySocial;CREATE TYPE EmploymentType AS CLOSED
{
`organization-name` : string,
`start-date` : date,
`end-date` : date?
};CREATE TYPE FacebookUserType AS CLOSED {
id : bigint,
alias : string,
name : string,
`user-since` : datetime,
`friend-ids` : {{bigint}},
employment : [EmploymentType]
};CREATE TYPE FacebookMessageType AS CLOSED {
`message-id` : bigint,
`author-id` : bigint,
`in-response-to` : bigint?,
`sender-location` : point?,
message : string
};CREATE DATASET FacebookUsers(FacebookUserType) PRIMARY KEY id;CREATE DATASET FacebookMessages(FacebookMessageType) PRIMARY KEY `message-id`; {code}
Query:
{code:java}
USE TinySocial;
-- Disabled for a simpler plan
SET `compiler.sort.parallel` "false";EXPLAIN
SELECT s.`message-id` id, object_remove(s, "in-response-to") no_in_response_to
FROM FacebookMessages AS s
UNION ALL
SELECT t user
FROM FacebookUsers t
UNION ALL
SELECT s.`message-id` id, object_remove(s, "author-id") no_author_id
FROM FacebookMessages s
ORDER BY id;
{code}
Plan:
{code:java}
...
-- UNION_ALL |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
project ([$$65, $$131])
-- STREAM_PROJECT |PARTITIONED|
assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]
-- ASSIGN |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
replicate
-- REPLICATE |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
data-scan []<-[$$65, $$s] <- TinySocial.FacebookMessages
-- DATASOURCE_SCAN |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
empty-tuple-source
-- EMPTY_TUPLE_SOURCE |PARTITIONED|
...{code}
The second cast in :
{code:java}
assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]{code}
is useless as it casts to the same type
The issue is the ARecordType deepEqual which also compares {*}allPossibleAdditionalFieldNames{*}, which is an integral part of the record type but an information used by the compiler to determine the possible fields that could exist in open part
was:
DDL:
{code:java}
DROP DATAVERSE TinySocial IF EXISTS;
CREATE DATAVERSE TinySocial;USE TinySocial;CREATE TYPE EmploymentType AS CLOSED
{
`organization-name` : string,
`start-date` : date,
`end-date` : date?
};CREATE TYPE FacebookUserType AS CLOSED {
id : bigint,
alias : string,
name : string,
`user-since` : datetime,
`friend-ids` : {{bigint}},
employment : [EmploymentType]
};CREATE TYPE FacebookMessageType AS CLOSED {
`message-id` : bigint,
`author-id` : bigint,
`in-response-to` : bigint?,
`sender-location` : point?,
message : string
};CREATE DATASET FacebookUsers(FacebookUserType) PRIMARY KEY id;CREATE DATASET FacebookMessages(FacebookMessageType) PRIMARY KEY `message-id`; {code}
Query:
{code:java}
USE TinySocial;
-- Disabled for a simpler plan
SET `compiler.sort.parallel` "false";EXPLAIN
SELECT s.`message-id` id, object_remove(s, "in-response-to") no_in_response_to
FROM FacebookMessages AS s
UNION ALL
SELECT t user
FROM FacebookUsers t
UNION ALL
SELECT s.`message-id` id, object_remove(s, "author-id") no_author_id
FROM FacebookMessages s
ORDER BY id;
{code}
Plan:
{code:java}
...
-- UNION_ALL |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
project ([$$65, $$131])
-- STREAM_PROJECT |PARTITIONED|
assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]
-- ASSIGN |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
replicate
-- REPLICATE |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
data-scan []<-[$$65, $$s] <- TinySocial.FacebookMessages
-- DATASOURCE_SCAN |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
empty-tuple-source
-- EMPTY_TUPLE_SOURCE |PARTITIONED|
...{code}
The second cast in :
{code:java}
assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]{code}
is useless as it casts to the same type
The issue is the ARecordType deepEqual which also compares {*}allPossibleAdditionalFieldNames{*}, which is an integral part of the record type but an information used by the compiler to determine the possible fields that could exist in open part
> Remove useless casts for union all
> ----------------------------------
>
> Key: ASTERIXDB-3087
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-3087
> Project: Apache AsterixDB
> Issue Type: Bug
> Reporter: Wail Y. Alkowaileet
> Assignee: Wail Y. Alkowaileet
> Priority: Major
>
> DDL:
> {code:java}
> DROP DATAVERSE TinySocial IF EXISTS;
> CREATE DATAVERSE TinySocial;USE TinySocial;CREATE TYPE EmploymentType AS CLOSED
> {
> `organization-name` : string,
> `start-date` : date,
> `end-date` : date?
> };CREATE TYPE FacebookUserType AS CLOSED {
> id : bigint,
> alias : string,
> name : string,
> `user-since` : datetime,
> `friend-ids` : {{bigint}},
> employment : [EmploymentType]
> };CREATE TYPE FacebookMessageType AS CLOSED {
> `message-id` : bigint,
> `author-id` : bigint,
> `in-response-to` : bigint?,
> `sender-location` : point?,
> message : string
> };CREATE DATASET FacebookUsers(FacebookUserType) PRIMARY KEY id;CREATE DATASET FacebookMessages(FacebookMessageType) PRIMARY KEY `message-id`; {code}
>
> Query:
> {code:java}
> USE TinySocial;
> -- Disabled for a simpler plan
> SET `compiler.sort.parallel` "false";EXPLAIN
> SELECT s.`message-id` id, object_remove(s, "in-response-to") no_in_response_to
> FROM FacebookMessages AS s
> UNION ALL
> SELECT t user
> FROM FacebookUsers t
> UNION ALL
> SELECT s.`message-id` id, object_remove(s, "author-id") no_author_id
> FROM FacebookMessages s
> ORDER BY id;
> {code}
>
> Plan:
> {code:java}
> ...
> -- UNION_ALL |PARTITIONED|
> exchange
> -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
> project ([$$65, $$131])
> -- STREAM_PROJECT |PARTITIONED|
> assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]
> -- ASSIGN |PARTITIONED|
> exchange
> -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
> replicate
> -- REPLICATE |PARTITIONED|
> exchange
> -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
> data-scan []<-[$$65, $$s] <- TinySocial.FacebookMessages
> -- DATASOURCE_SCAN |PARTITIONED|
> exchange
> -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
> empty-tuple-source
> -- EMPTY_TUPLE_SOURCE |PARTITIONED|
> ...{code}
>
> The second cast in :
> {code:java}
> assign [$$131] <- [cast(cast({\"id\": $$65, \"no_in_response_to\": object-remove($$s, \"in-response-to\")}))]{code}
> is useless as it casts to the same type
> The issue is the ARecordType deepEqual which also compares {*}allPossibleAdditionalFieldNames{*}, which is an integral part of the record type but an information used by the compiler to determine the possible fields that could exist in open part
--
This message was sent by Atlassian Jira
(v8.20.10#820010)