confluentinc/ksql

Two different behavior using REGEX_EXTRACT scalar function

Open

#7792 aperta il 15 lug 2021

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Java (1048 fork)batch import
bugfix-it-weekgood first issuequery-engineuser-defined-functions

Metriche repository

Star
 (5739 star)
Metriche merge PR
 (Merge medio 4g 20h) (6 PR mergiate in 30 g)

Descrizione

Describe the bug Two different behaviors when inject statements with the CLI and the Control Center when using REGEX_EXTRACT scalar function

To Reproduce

  1. 0.18.0
{
  "id": "1234",
  "_data": {
    "referral_fields": "<ReferralFields version=\"1.0\"><TestCode>7621</TestCode><TestBarcode>33025016962</TestBarcode><Diagnoses><Diagnosis><Code>Y20185</Code><Description>EXAMINATION POSTPARTUM</Description><Attribute1/><Attribute2/><Comments/></Diagnosis></Diagnoses><TestReason/><Description/><PregnancyAge/><LastPeriodDate/><Menopause/><IUD/><Comments/><MainDiagnoses><MainDiagnosis><Code>Y11746</Code><Description>HYPERLIPIDEMIA</Description><Attribute1>M/P</Attribute1><Attribute2/><Comments>due to contraseptive</Comments></MainDiagnosis></MainDiagnoses><ChronicMedications/><DrugAllergies/><Allergies><Allergy><Name>הרדמה מקומית בעבר תקינה</Name><Expression/></Allergy><Allergy><Name>לא ידועה רגישות לתרופות</Name><Expression/></Allergy><Allergy><Name>לא ידוע</Name><Expression/></Allergy><Allergy><Name>NO</Name><Expression/></Allergy></Allergies></ReferralFields>"
  }
}
  1. Any SQL statements you ran
SET 'auto.offset.reset'='earliest';

create stream `referral_fields`
	(`id` string key,`_data` struct<`referral_fields` string>)
     with 
     (kafka_topic='<some topic>',value_format='json');

create table `barcodes` as 
select regexp_extract('(\<testbarcode\>)([0-9]+)\w',LCASE(`_data`->`referral_fields`), 2) as `barcode`,
       count(*) as `count`
from `referral_fields` 
where regexp_extract('(\<testbarcode\>)([0-9]+)\w',LCASE(`_data`->`referral_fields`), 2) is not null
group by regexp_extract('(\<testbarcode\>)([0-9]+)\w',LCASE(`_data`->`referral_fields`), 2)
emit changes;

Expected behavior Project the message to the table regardless which client the statement injected

Actual behavior

  1. created stream and table successfully
  2. No errors
  3. N/A

Additional context acts different because of the \w addition char in the end of the regex. although the \w eventually was not necessary in the regex, i expect it to act the same regardless the client i used.

if I inject the statement though the cli its not working, but through the Control Center, its working

Guida contributor