简体   繁体   English

Hive XOR函数用于字符串?

[英]Hive XOR function for string?

I want to select a data either A column equals 'X' or B column equals 'X' but not both of them equal 'X'. 我想选择一个数据,要么A列等于“ X”,要么B列等于“ X”,但不是两个都等于“ X”。 Is there such a function in HQL? HQL中有这样的功能吗?

Try below query instead of tablename use your tablename 尝试在下面的查询而不是表名中使用您的表名

    SELECT * FROM ( 
       SELECT
        CASE WHEN COLUMNA='X' AND COLUMNB<>'X' THEN COLUMNA 
        CASE WHEN COLUMNA<>'X' AND COLUMNB='X' THEN COLUMNB 
        END AS XORCOMBO
        FROM TABLENAME
                 )X
WHERE XORCOMBO IS NOT NULL

Hive does have bitwise XOR arithmetic operator. Hive确实具有按位XOR算术运算符。 It can be used on any numeric data type for ex. 它可以用于ex的任何数字数据类型。 A ^ B . A ^ B

More details can be found in hive official documentation: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-ArithmeticOperators 可以在hive官方文档中找到更多详细信息: https : //cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-ArithmeticOperators

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C中的字符串XOR函数:如何处理空字符? - string XOR function in C: How to deal with null characters? 如何使用相同的功能对C中的字符串进行XOR加扰并再次返回? - How to XOR scramble a string in C and back again with the same function? Mysql:xor带有键的字符串 - Mysql: xor a string with a key 使用JavaScript实现PHP字符串异或 - Implement PHP string xor with JavaScript 将int转换为String,然后使用XOR对其进行加密 - Converting an int to a String and then encrypt it with XOR str_to_hive 函数将字符串的每个字符拆分为 key - str_to_hive function splits each character of the string as key 如何在hive中的array_contains函数中模式匹配字符串表达式? - How to pattern match string expression in array_contains function in hive? 如何将字符串转换为位然后将其分成两半并对一部分执行一些功能,然后将其与另一个进行异或然后使用 java 交换? - How can I convert string to bit then split it in half and do some function on a part and then xor it with the other then swap using java? 异或后将十六进制字符串转换为ASCII - Hex string convert to ASCII after XOR 如何将十进制转换为十六进制字符串的十六进制和XOR - How to convert decimal to hexadecimal and XOR of the hex string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM