confluentinc/ksql

Two different behavior using REGEX_EXTRACT scalar function

Open

#7.792 geöffnet am 15. Juli 2021

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (1.048 Forks)batch import
bugfix-it-weekgood first issuequery-engineuser-defined-functions

Repository-Metriken

Stars
 (5.739 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 4T 20h) (6 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide