On Sunday, February 22, 2015 at 8:01:04 AM UTC-5, Yan Yan wrote:
Q1. How could I trim trailing null characters from a string column?
In addition to Charles’ solution, note that nulls are trimmed when you convert strings to symbols:
q)`$“ABCDEFGHI\000”
`ABCDEFGHI
q)string`$“ABCDEFGHI\000”
“ABCDEFGHI”
You may not want to use the round-trip as a general-purpose trim (`$ pollutes the symbol cache), but if your data is destined for a sym column, you can omit the trim.
Q2. How to perform this query: select sym, strlen(raw) from test_table
On Wednesday, February 25, 2015 at 2:46:25 AM UTC-5, Yan Yan wrote:
> convert strings to symbols
That sinks into the irrecoverable interned symbol string memory pool.
Yes, that’s why I wrote: “You may not want to use the round-trip as a general-purpose trim (`$ pollutes the symbol cache), but if your data is destined for a sym column, you can omit the trim.”
On Wednesday, February 25, 2015 at 12:31:49 AM UTC+8, Alexander Belopolsky wrote:
On Sunday, February 22, 2015 at 8:01:04 AM UTC-5, Yan Yan wrote:
Q1. How could I trim trailing null characters from a string column?
In addition to Charles’ solution, note that nulls are trimmed when you convert strings to symbols:
q)`$“ABCDEFGHI\000”
`ABCDEFGHI
q)string`$“ABCDEFGHI\000”
“ABCDEFGHI”
You may not want to use the round-trip as a general-purpose trim (`$ pollutes the symbol cache), but if your data is destined for a sym column, you can omit the trim.
Q2. How to perform this query: select sym, strlen(raw) from test_table