Saving all output to "!!{outputDirectory}!!/udf_reverse.q.raw". Enter "record" with no arguments to stop it. >>> !run !!{qFileDirectory}!!/udf_reverse.q >>> DESCRIBE FUNCTION reverse; 'tab_name' 'reverse(str) - reverse str' 1 row selected >>> DESCRIBE FUNCTION EXTENDED reverse; 'tab_name' 'reverse(str) - reverse str' 'Example:' ' > SELECT reverse('Facebook') FROM src LIMIT 1;' ' 'koobecaF'' 4 rows selected >>> >>> CREATE TABLE dest1(len STRING); No rows affected >>> EXPLAIN FROM src1 INSERT OVERWRITE TABLE dest1 SELECT reverse(src1.value); 'Explain' 'ABSTRACT SYNTAX TREE:' ' (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src1))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME dest1))) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTION reverse (. (TOK_TABLE_OR_COL src1) value))))))' '' 'STAGE DEPENDENCIES:' ' Stage-1 is a root stage' ' Stage-7 depends on stages: Stage-1 , consists of Stage-4, Stage-3, Stage-5' ' Stage-4' ' Stage-0 depends on stages: Stage-4, Stage-3, Stage-6' ' Stage-2 depends on stages: Stage-0' ' Stage-3' ' Stage-5' ' Stage-6 depends on stages: Stage-5' '' 'STAGE PLANS:' ' Stage: Stage-1' ' Map Reduce' ' Alias -> Map Operator Tree:' ' src1 ' ' TableScan' ' alias: src1' ' Select Operator' ' expressions:' ' expr: reverse(value)' ' type: string' ' outputColumnNames: _col0' ' File Output Operator' ' compressed: false' ' GlobalTableId: 1' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: udf_reverse.dest1' '' ' Stage: Stage-7' ' Conditional Operator' '' ' Stage: Stage-4' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: pfile:!!{hive.exec.scratchdir}!!' '' ' Stage: Stage-0' ' Move Operator' ' tables:' ' replace: true' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: udf_reverse.dest1' '' ' Stage: Stage-2' ' Stats-Aggr Operator' '' ' Stage: Stage-3' ' Map Reduce' ' Alias -> Map Operator Tree:' ' pfile:!!{hive.exec.scratchdir}!! ' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: udf_reverse.dest1' '' ' Stage: Stage-5' ' Map Reduce' ' Alias -> Map Operator Tree:' ' pfile:!!{hive.exec.scratchdir}!! ' ' File Output Operator' ' compressed: false' ' GlobalTableId: 0' ' table:' ' input format: org.apache.hadoop.mapred.TextInputFormat' ' output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' ' serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' ' name: udf_reverse.dest1' '' ' Stage: Stage-6' ' Move Operator' ' files:' ' hdfs directory: true' ' destination: pfile:!!{hive.exec.scratchdir}!!' '' '' 89 rows selected >>> FROM src1 INSERT OVERWRITE TABLE dest1 SELECT reverse(src1.value); '_c0' No rows selected >>> SELECT dest1.* FROM dest1; 'len' '832_lav' '' '113_lav' '72_lav' '561_lav' '904_lav' '552_lav' '872_lav' '89_lav' '484_lav' '562_lav' '391_lav' '104_lav' '051_lav' '372_lav' '' '' '66_lav' '' '312_lav' '641_lav' '604_lav' '' '' '' 25 rows selected >>> DROP TABLE dest1; No rows affected >>> >>> -- Test with non-ascii characters >>> -- kv4.txt contains the text 0xE982B5E993AE, which should be reversed to >>> -- 0xE993AEE982B5 >>> CREATE TABLE dest1(name STRING) STORED AS TEXTFILE; No rows affected >>> LOAD DATA LOCAL INPATH '../data/files/kv4.txt' INTO TABLE dest1; No rows affected >>> SELECT count(1) FROM dest1 WHERE reverse(dest1.name) = _UTF-8 0xE993AEE982B5; '_c0' '1' 1 row selected >>> !record