Skip to content

Sql parse bug #2374

@rockpal

Description

@rockpal

version: 1.0.0-rc.3
SQL:SELECT * FROM ( with base as ( select sum(a.sale_amount) as sale_amount, sum(a.profit)/nullif(sum(a.sale_amount), 0) as profit_rate, sum(a.profit) as profit, sum(a.sale_amount)/nullif(sum(a.sheet_qty), 0) as avg_sheet_price, sum(a.sheet_qty) as sheet_qty from data_center.ads_sale_store_cate1_by_day_sq a where a.sdate >= date_format(curdate(),'%Y-%m-01') and a.sdate <= date_sub(curdate(),interval 1 day) AND ( CASE WHEN '$STORE_ID$'='' OR '$STORE_ID$' IS NULL THEN 1=1 ELSE find_in_set (a.store_id, '$STORE_ID$') END ) AND a.cate1_id IN ( SELECT enum_value FROM data_center.dim_enum WHERE enum_name = 'fresh_id' ) ), ly_base as ( select sum(a.sale_amount) as sale_amount, sum(a.profit)/nullif(sum(a.sale_amount), 0) as profit_rate, sum(a.profit) as profit, sum(a.sale_amount)/nullif(sum(a.sheet_qty), 0) as avg_sheet_price, sum(a.sheet_qty) as sheet_qty from data_center.ads_sale_store_cate1_by_day_sq a where a.sdate >= DATE_SUB(DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 1 WEEK), INTERVAL 1 DAY) and a.sdate <= DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 1 WEEK) AND a.cate1_id IN ( SELECT enum_value FROM data_center.dim_enum WHERE enum_name = 'fresh_id' ) ) select a.sale_amount, a.profit_rate, a.profit, a.avg_sheet_price, a.sheet_qty, b.sale_amount as sale_amount_ly, b.profit_rate as profit_rate_ly, b.profit as profit_ly, b.avg_sheet_price as avg_sheet_price_ly, b.sheet_qty as sheet_qty_ly, (a.sale_amount - b.sale_amount)/nullif(b.sale_amount, 0) as yoy_sale_amount, (a.profit_rate - b.profit_rate)/nullif(b.profit_rate, 0) as yoy_profit_rate, (a.profit - b.profit)/nullif(b.profit, 0) as yoy_profit, (a.avg_sheet_price - b.avg_sheet_price)/nullif(b.avg_sheet_price, 0) as yoy_avg_sheet_price, (a.sheet_qty - b.sheet_qty)/nullif(b.sheet_qty, 0) as yoy_sheet_qty from base a left join ly_base b on 1 = 1 ) AS DATART_VTABLE LIMIT 1000 OFFSET 0
DB: MYSQL
EXCEPTION:org.apache.calcite.sql.parser.SqlParseException: Encountered "WEEK" at line 1, column 1206.
Was expecting one of:
"DAY" ...
"DAYS" ...
"HOUR" ...
"HOURS" ...
"MINUTE" ...
"MINUTES" ...
"MONTH" ...
"MONTHS" ...
"SECOND" ...
"SECONDS" ...
"YEAR" ...
"YEARS" ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions