Hi Ramya, Fabian is right. The behavior in strict SQL standard mode(SQL:2003) returns a CHAR(N) type with blank-padded.
Best, Hequn On Wed, Jan 30, 2019 at 1:59 AM Fabian Hueske <fhue...@gmail.com> wrote: > Hi, > > Table API queries are executed with SQL semantics. > In SQL, the strings are padded because the result data type is not a > VARCHAR but a CHAR with as many character as the longest string. > You can use the RTRIM function to remove the padding whitespaces. > > Best, Fabian > > > Am Di., 29. Jan. 2019 um 15:08 Uhr schrieb Ramya Ramamurthy < > hair...@gmail.com>: > > > Hi, > > > > I have encountered a weird issue. When constructing a Table Query with > CASE > > Statements, like below: > > .append("CASE ") > > .append("WHEN aggrcat = '0' AND botcode='r4' THEN 'monitoring' ") > > .append("WHEN aggrcat = '1' AND botcode='r4' THEN 'aggregator' ") > > .append("WHEN aggrcat = '2' AND botcode='r4' THEN 'social network' ") > > .append("WHEN botcode='r0' OR botcode='r8' THEN 'crawler' ") > > > > Followed by converting to a stream: > > DataStream<Row> ds = tableEnv.toAppendStream(table_name, Row.Class) > > ds.print() > > > > I can see that while I print this, it takes the length of the longest > > string of all the four categories and appends spaces till that length. > > Eg. Crawler is of length of the biggest string [social network mayb]. > > > > This affects when my data is sinked to ES. The fields are appended with > > empty spaces, which affects the querying. > > > > I know i can do a simple split to eliminate these spaces in my code, but > > just curious to understand why this behavior. It becomes cumbersome to > > maintain code this way and for readability as well. > > > > ~Ramya. > > >