Search code examples
sqlkdbvertica

Split_Part equivalent for Kdb+


working through using Kdb, not as familiar with our schema and tables..so still learning here.

But there is a column a called Action with string values: Behavior|5*100-6*200|StrategyXYZ

In sql, I can split this string like

split_part(Action, "|", 3,) Behavior -> StrategyXYZ

What is the equivalent for kdb?


Solution

  • You can use vs to split the string by delimiter and take the element at desired index. You can wrap this into a single function like so:

    f: {(y vs x) [z]}
    f["yourstring";"|";2]  /for single string
    select f[;"|";2] each yourstringcolumn from yourtable /for a column in table