[ 
https://issues.apache.org/jira/browse/HIVE-24389?focusedWorklogId=516598&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-516598
 ]

ASF GitHub Bot logged work on HIVE-24389:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Nov/20 10:29
            Start Date: 25/Nov/20 10:29
    Worklog Time Spent: 10m 
      Work Description: kasakrisz commented on a change in pull request #1676:
URL: https://github.com/apache/hive/pull/1676#discussion_r530266544



##########
File path: 
ql/src/test/results/clientpositive/llap/materialized_view_rewrite_window.q.out
##########
@@ -166,7 +166,7 @@ POSTHOOK: Input: arc_view@wealth
 #### A masked pattern was here ####
 CBO PLAN:
 HiveSortLimit(sort0=[$0], dir0=[ASC])
-  HiveProject(quartile=[$0], total=[$1])
+  HiveProject(quartile=[CAST($0):DECIMAL(12, 1)], total=[$1])

Review comment:
       The optimiziter rewrites this query to use materialized view 
`mv_tv_view_data_av1`.
   The plan of the mv with this patch is changed
   from
   ```
   HiveTableScan(table=[[arc_view, mv_tv_view_data_av1]], 
table:alias=[mv_tv_view_data_av1])
   ```
   to
   ```
   LogicalProject(quartile=[CAST($0):DECIMAL(12, 1)], total=[$1])
     HiveTableScan(table=[[arc_view, mv_tv_view_data_av1]], 
table:alias=[mv_tv_view_data_av1])
   ```
   The mv definition contains a constant value cast to Decimal `cast(1.5 as 
decimal(9,4))`
   ```
   create materialized view mv_tv_view_data_av1 stored as orc TBLPROPERTIES 
('transactional'='true') as
   select
     t.quartile,
     max(t.total_views) total
   from wealth t2,
   (select
     total_views `total_views`,
     sum(cast(1.5 as decimal(9,4))) over (order by total_views) as quartile,
     program
   from tv_view_data) t
   where t.program=t2.watches
   group by quartile;
   ```
   
   We need the project with the cast on top of the mv scan because the mv table 
schema is different than the query schema. 
   RowTypes after the patch
   ```
   viewscan rowType: RecordType(DECIMAL(12, 4) quartile, BIGINT total)
   queryRel rowType: RecordType(DECIMAL(12, 1) quartile, BIGINT $f1)
   ```
   before the patch
   ```
   viewscan rowType: RecordType(DECIMAL(12, 1) quartile, BIGINT total)
   queryRel rowType: RecordType(DECIMAL(12, 1) quartile, BIGINT $f1)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 516598)
    Time Spent: 1h 50m  (was: 1h 40m)

> Trailing zeros of constant decimal numbers are removed
> ------------------------------------------------------
>
>                 Key: HIVE-24389
>                 URL: https://issues.apache.org/jira/browse/HIVE-24389
>             Project: Hive
>          Issue Type: Bug
>          Components: Types
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> In some case Hive removes trailing zeros of constant decimal numbers
> {code}
> select cast(1.1 as decimal(22, 2)) 
> 1.1
> {code}
> In this case *WritableConstantHiveDecimalObjectInspector* is used and this 
> object inspector takes it's wrapped HiveDecimal scale instead of the scale 
> specified in the wrapped typeinfo: 
> {code}
> this = {WritableConstantHiveDecimalObjectInspector@14415} 
>  value = {HiveDecimalWritable@14426} "1.1"
>  typeInfo = {DecimalTypeInfo@14421} "decimal(22,2)"{code}
> However in case of an expression with an aggregate function 
> *WritableHiveDecimalObjectInspector* is used
> {code}
> select cast(sum(1.1) as decimal(22, 2))
> 1.10
> {code}
> {code}
> o = {HiveDecimalWritable@16633} "1.1"
> oi = {WritableHiveDecimalObjectInspector@16634} 
>  typeInfo = {DecimalTypeInfo@16640} "decimal(22,2)"
> {code}
> Casting the expressions to string
> {code:java}
> select cast(cast(1.1 as decimal(22, 2)) as string), cast(cast(sum(1.1) as 
> decimal(22, 2)) as string)
> 1.1   1.10
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to