Github user wuchong commented on a diff in the pull request: https://github.com/apache/flink/pull/4128#discussion_r127866461 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala --- @@ -82,4 +82,24 @@ object ScalarFunctions { } sb.toString } + + /** + * Returns a string representation of the binary value of N, Returns NULL if N is NULL. + */ + def bin(n: Long): String = { + if (null == n) { + return null + } + val value = new Array[Byte](64) + var num = n + // Extract the bits of num into value[] from right to left + var len: Int = 0 + do { + len += 1 + value(value.length - len) = ('0' + (num & 1)).toByte + num >>>= 1 + } while (num != 0) --- End diff -- Use `Long.toBinaryString(long)` to parse it.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---