-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
567 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package doric | ||
package syntax | ||
|
||
import doric.types.{BinaryType, SparkType} | ||
import org.apache.spark.sql.{functions => f} | ||
|
||
private[syntax] trait BinaryColumns { | ||
|
||
implicit class BinaryOperationsSyntax[T: BinaryType: SparkType]( | ||
column: DoricColumn[T] | ||
) { | ||
|
||
/** | ||
* Calculates the MD5 digest of a binary column and returns the value | ||
* as a 32 character hex string. | ||
* | ||
* @group All Types | ||
*/ | ||
def md5: StringColumn = column.elem.map(f.md5).toDC | ||
|
||
/** | ||
* Calculates the SHA-1 digest of a binary column and returns the value | ||
* as a 40 character hex string. | ||
* | ||
* @group All Types | ||
*/ | ||
def sha1: StringColumn = column.elem.map(f.sha1).toDC | ||
|
||
/** | ||
* Calculates the SHA-2 family of hash functions of a binary column and | ||
* returns the value as a hex string. | ||
* | ||
* @group All Types | ||
*/ | ||
def sha2(numBits: Int): StringColumn = | ||
column.elem.map(x => f.sha2(x, numBits)).toDC | ||
|
||
/** | ||
* Calculates the cyclic redundancy check value (CRC32) of a binary column and | ||
* returns the value as a long column. | ||
* | ||
* @group All Types | ||
*/ | ||
def crc32: LongColumn = | ||
column.elem.map(f.crc32).toDC | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.