Saving all output to "!!{outputDirectory}!!/udf_field.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/udf_field.q >>> DESCRIBE FUNCTION field; 'tab_name' 'field(str, str1, str2, ...) - returns the index of str in the str1,str2,... list or 0 if not found' 1 row selected >>> DESCRIBE FUNCTION EXTENDED field; 'tab_name' 'field(str, str1, str2, ...) - returns the index of str in the str1,str2,... list or 0 if not found' 'All primitive types are supported, arguments are compared using str.equals(x). If str is NULL, the return value is 0.' 2 rows selected >>> >>> SELECT field("x", "a", "b", "c", "d"), field(NULL, "a", "b", "c", "d"), field(0, 1, 2, 3, 4) FROM src LIMIT 1; '_c0','_c1','_c2' '0','0','0' 1 row selected >>> >>> SELECT field("a", "a", "b", "c", "d"), field("b", "a", "b", "c", "d"), field("c", "a", "b", "c", "d"), field("d", "a", "b", "c", "d"), field("d", "a", "b", NULL, "d") FROM src LIMIT 1; '_c0','_c1','_c2','_c3','_c4' '1','2','3','4','4' 1 row selected >>> >>> SELECT field(1, 1, 2, 3, 4), field(2, 1, 2, 3, 4), field(3, 1, 2, 3, 4), field(4, 1, 2, 3, 4), field(4, 1, 2, NULL, 4) FROM src LIMIT 1; '_c0','_c1','_c2','_c3','_c4' '1','2','3','4','4' 1 row selected >>> >>> >>> CREATE TABLE test_table(col1 STRING, col2 STRING) STORED AS TEXTFILE; No rows affected >>> LOAD DATA LOCAL INPATH '../data/files/kv1.txt' INTO TABLE test_table; No rows affected >>> >>> select col1,col2, field("66",col1), field("66",col1, col2), field("val_86",col1, col2), field(NULL, col1, col2), field(col1, 66, 88), field(col1, "66", "88"), field(col1, "666", "888"), field(col2, "66", "88"), field(col1, col2, col1), field(col1, col2, "66") from test_table where col1="86" or col1="66"; 'col1','col2','_c2','_c3','_c4','_c5','_c6','_c7','_c8','_c9','_c10','_c11' '86','val_86','0','0','2','0','0','0','0','0','2','0' '66','val_66','1','1','0','0','0','1','0','0','2','2' 2 rows selected >>> >>> >>> CREATE TABLE test_table1(col1 int, col2 string) STORED AS TEXTFILE; No rows affected >>> LOAD DATA LOCAL INPATH '../data/files/kv1.txt' INTO TABLE test_table1; No rows affected >>> >>> select col1,col2, field(66,col1), field(66,col1, col2), field(86, col2, col1), field(86, col1, col1), field(86,col1,n,col2), field(NULL,col1,n,col2), field(col1, col2) from (select col1, col2, NULL as n from test_table1 where col1=86 or col1=66) t; 'col1','col2','_c2','_c3','_c4','_c5','_c6','_c7','_c8' '86','val_86','0','0','2','1','1','0','0' '66','val_66','1','1','0','0','0','0','0' 2 rows selected >>> !record