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

panic when counting a jsonb value #10838

Closed
docteurklein opened this issue Jul 9, 2023 · 2 comments
Closed

panic when counting a jsonb value #10838

docteurklein opened this issue Jul 9, 2023 · 2 comments
Labels
type/bug Something isn't working
Milestone

Comments

@docteurklein
Copy link

docteurklein commented Jul 9, 2023

Describe the bug

Hey there, had to observe the logs to understand that I can't count a jsonb value. In the meantime I can count(*), but not count(pv.*), pv being an alias for a mat view.

Error message/log

thread 'thread 'risingwave-streaming-actor' panicked at 'streaming agg state not implemented: Count
Jsonb Int64', src/stream/src/executor/aggregation/agg_impl/mod.rs:157:13

To Reproduce

everything is reproducible at https://github.com/docteurklein/risingwave-demo

create schema pim1;

create table pim1.product (
  uuid bytea,
  family_id int,
  product_model_id int,
  family_variant_id int,
  id int,
  is_enabled bool,
  identifier text,
  raw_values jsonb,
  created timestamptz,
  updated timestamptz,
  quantified_associations jsonb,
  primary key (uuid)
) with (
 connector = 'mysql-cdc',
 hostname = 'mysql',
 port = '3306',
 username = 'root',
 password = 'root',
 database.name = 'pim1',
 table.name = 'pim_catalog_product',
 server.id = '1'
);

drop sink if exists product_stats;
drop materialized view if exists pim1.product_value;

create materialized view pim1.product_value as
  with by_raw_value (product_id, rest) as (
    select id, jsonb_each(raw_values) from pim1.product
  ),
  by_attr (product_id, attribute, rest) as (
    select product_id, (rest).key, jsonb_each((rest).value)
    from by_raw_value
  ),
  by_channel (product_id, attribute, channel, rest) as (
    select product_id, attribute, nullif((rest).key, '<all_channels>'), jsonb_each((rest).value)
    from by_attr
  ),
  by_locale (product_id, attribute, channel, locale, value) as (
    select product_id, attribute, channel, nullif((rest).key, '<all_locales>'), (rest).value
    from by_channel
  )
  select * from by_locale
;

create sink product_stats as
select coalesce(p.family_id, 0) family, count(*) as num_values
from pim1.product_value pv
inner join pim1.product p on (pv.product_id = p.id)
group by 1
with (
    connector='jdbc',
    jdbc.url='jdbc:mysql://mysql:3306/pim1?user=root&password=root',
    table.name='product_stats',
    type='upsert'
);

Expected behavior

I expected a better error message, and optionaly to be able to do that like in postgres.

How did you deploy RisingWave?

using docker-compose but with a single playground service`

The version of RisingWave

select version(); -- PostgreSQL 8.3-RisingWave-1.0.0-alpha (2b6d7d6)
docker image: risingwavelabs/risingwave:nightly-20230709

Additional context

No response

@docteurklein docteurklein added the type/bug Something isn't working label Jul 9, 2023
@github-actions github-actions bot added this to the release-0.20 milestone Jul 9, 2023
@xiangjinwu
Copy link
Contributor

xiangjinwu commented Jul 10, 2023

Thanks for the bug report!

Regarding the panic on count(jsonb) in streaming (mat view), it would not be an issue after the refactor mentioned in #10752 (comment) . But we can also do a quick fix.

As for count(pv.*), it is equivalent to count(pv) and we would enhance our support as part of #9694. Before that you can use count(*) as long as there are no outer joins, or use count(pv.foo) when it is okay not to distinguish foo is null vs pv is not distinct from null during an outer join.

@docteurklein docteurklein changed the title panick when counting a jsonb value panic when counting a jsonb value Jul 10, 2023
@xiangjinwu
Copy link
Contributor

count(jsonb) in streaming has been fixed. count(pv.*) in outer join will be tracked by #10847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants