Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/6721#discussion_r32652438
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/math.scala
---
@@ -205,6 +217,26 @@ case class ToRadians(child: Expression) extends
UnaryMathExpression(math.toRadia
override def funcName: String = "toRadians"
}
+case class Bin(child: Expression)
+ extends AbstractUnaryMathExpression[Long, String]("BIN") {
+
+ override def expectedChildTypes: Seq[DataType] = Seq(LongType)
+ override def dataType: DataType = StringType
+
+ override def eval(input: catalyst.InternalRow): Any = {
+ val evalE = child.eval(input)
+ if (evalE == null) {
+ null
+ } else {
+ UTF8String.fromString(JLong.toBinaryString(evalE.asInstanceOf[Long]))
+ }
+ }
+
+ override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode):
String = {
+ defineCodeGen(ctx, ev, (c) =>
+
s"org.apache.spark.unsafe.types.UTF8String.fromString(java.lang.Long.toBinaryString($c))")
--- End diff --
"org.apache.spark.unsafe.types.UTF8String" could be `${ctx.stringType}`
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]