You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by br...@apache.org on 2019/04/12 19:50:11 UTC
[drill] branch gh-pages updated: regexp_matches doc update
This is an automated email from the ASF dual-hosted git repository.
bridgetb pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/gh-pages by this push:
new eab6efd regexp_matches doc update
eab6efd is described below
commit eab6efdad55955c950ae3b5f05849c969b2df952
Author: Bridget Bevens <bb...@maprtech.com>
AuthorDate: Fri Apr 12 12:49:08 2019 -0700
regexp_matches doc update
---
.../sql-functions/040-string-manipulation.md | 48 ++++++++++++++-
.../sql-functions/063-cryptography-functions.md | 68 ++++++++++++++++++++++
2 files changed, 114 insertions(+), 2 deletions(-)
diff --git a/_docs/sql-reference/sql-functions/040-string-manipulation.md b/_docs/sql-reference/sql-functions/040-string-manipulation.md
index a4cf192..6e6077f 100644
--- a/_docs/sql-reference/sql-functions/040-string-manipulation.md
+++ b/_docs/sql-reference/sql-functions/040-string-manipulation.md
@@ -1,6 +1,6 @@
---
title: "String Manipulation"
-date: 2016-01-14
+date: 2019-04-12
parent: "SQL Functions"
---
@@ -18,6 +18,7 @@ Function| Return Type
[LPAD]({{ site.baseurl }}/docs/string-manipulation/#lpad)| VARCHAR
[LTRIM]({{ site.baseurl }}/docs/string-manipulation/#ltrim)| VARCHAR
[POSITION]({{ site.baseurl }}/docs/string-manipulation/#position)| INTEGER
+[REGEXP_MATCHES]({{ site.baseurl }}/docs/string-manipulation/#regexp_matches)|BOOLEAN
[REGEXP_REPLACE]({{ site.baseurl }}/docs/string-manipulation/#regexp_replace)|VARCHAR
[RPAD]({{ site.baseurl }}/docs/string-manipulation/#rpad)| VARCHAR
[RTRIM]({{ site.baseurl }}/docs/string-manipulation/#rtrim)| VARCHAR
@@ -262,7 +263,50 @@ Returns the location of a substring.
+------------+
1 row selected (0.12 seconds)
-## REGEXP_REPLACE
+
+##REGEXP_MATCHES
+
+Matches a regexp pattern to a target string. Returns a boolean value; true if the value matches the regexp, false if the value does not match the regexp.
+
+###REGEXP_MATCHES Syntax
+
+REGEXP_MATCHES(string_expression, pattern)
+
+*string_expression* is the string to be matched.
+
+*pattern* is the regular expression.
+
+### REGEXP_MATCHES Examples
+
+Shows several POSIX metacharacters that return true for the given string expressions:
+
+ select regexp_matches('abc', 'abc|def') as a, regexp_matches('cat', '[hc]at$') as b, regexp_matches('cat', '.at') as c, regexp_matches('cat', '[hc]at') as d, regexp_matches('cat', '[^b]at') as e, regexp_matches('cat', '^[hc]at') as f, regexp_matches('[a]', '\[.\]') as g, regexp_matches('sat', 's.*') as h, regexp_matches('sat','[^hc]at') as i, regexp_matches('hat', '[hc]?at') as j, regexp_matches('cchchat', '[hc]*at') as k, regexp_matches('chat', '[hc]+at') as l;
+
+ +------+------+------+------+------+------+------+------+------+------+------+------+
+ | a | b | c | d | e | f | g | h | i | j | k | l |
+ +------+------+------+------+------+------+------+------+------+------+------+------+
+ | true | true | true | true | true | true | true | true | true | true | true | true |
+ +------+------+------+------+------+------+------+------+------+------+------+------+
+
+Shows case-sensitivity:
+
+ select regexp_matches('abc', 'A*.C');
+ +--------+
+ | EXPR$0 |
+ +--------+
+ | false |
+ +--------+
+
+ select regexp_matches('abc', 'a*.c');
+ +--------+
+ | EXPR$0 |
+ +--------+
+ | true |
+ +--------+
+
+
+
+##REGEXP_REPLACE
Substitutes new text for substrings that match [Java regular expression patterns](http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html).
diff --git a/_docs/sql-reference/sql-functions/063-cryptography-functions.md b/_docs/sql-reference/sql-functions/063-cryptography-functions.md
new file mode 100644
index 0000000..9ad37cb
--- /dev/null
+++ b/_docs/sql-reference/sql-functions/063-cryptography-functions.md
@@ -0,0 +1,68 @@
+---
+title: "Cryptography Functions"
+date: 2019-04-10 01:25:29 UTC
+parent: "SQL Functions"
+---
+
+Starting in version 1.11, Drill supports cryptography-related functions. The library of cryptography-related functions generally mirrors the crypto functions in MySQL, including:
+
+* **`aes_encrypt()`/ `aes_decrypt()`**: implement encryption and decryption of data using the official AES (Advanced Encryption Standard) algorithm, previously known as “Rijndael.”
+ `AES_ENCRYPT()` encrypts the string `str` using the key string `key_str` and returns a binary string containing the encrypted output. `AES_DECRYPT()` decrypts the encrypted string `crypt_str` using the key string `key_str` and returns the original cleartext string. If either function argument is NULL, the function returns NULL.
+
+
+ SELECT aes_encrypt( 'encrypted_text', 'my_secret_key' ) AS aes FROM (VALUES(1));
+ +---------------------------+
+ | aes |
+ +---------------------------+
+ | JkcBUNAn8ByKWCcVmNrKMA== |
+ +---------------------------+
+
+ SELECT aes_encrypt( 'encrypted_text', 'my_secret_key' ) AS encrypted,
+ aes_decrypt(aes_encrypt( 'encrypted_text', 'my_secret_key' ),'my_secret_key') AS decrypted
+ FROM (VALUES(1));
+ +---------------------------+-----------------+
+ | encrypted | decrypted |
+ +---------------------------+-----------------+
+ | JkcBUNAn8ByKWCcVmNrKMA== | encrypted_text |
+ +---------------------------+-----------------+
+
+
+* **`md2(<text>)`**: Returns the md2 hash of the text. (https://en.wikipedia.org/wiki/MD2_(cryptography))
+
+
+ select md2( 'testing' ) from (values(1));
+ +-----------------------------------+
+ | EXPR$0 |
+ +-----------------------------------+
+ | fc134df10d6ecafceb5c75861d01b41f |
+ +-----------------------------------+
+
+
+* **`md5(<text>)`**: Returns the md5 hash of the text. (https://en.wikipedia.org/wiki/MD5)
+
+ select md5( 'testing' ) from (VALUES(1));
+ +-----------------------------------+
+ | EXPR$0 |
+ +-----------------------------------+
+ | ae2b1fca515949e5d54fb22b8ed95575 |
+ +-----------------------------------+
+
+* **`sha(<text>`) / `sha1(<text>)`**: Calculates an SHA-1 160-bit checksum for the string, as described in RFC 3174 (Secure Hash Algorithm). (https://en.wikipedia.org/wiki/SHA-1) The value is returned as a string of 40 hexadecimal digits, or NULL if the argument was NULL. Note that `sha()` and `sha1()` are aliases for the same function.
+
+ select sha1( 'testing' ) from (VALUES(1));
+ +-------------------------------------------+
+ | EXPR$0 |
+ +-------------------------------------------+
+ | dc724af18fbdd4e59189f5fe768a5f8311527050 |
+ +-------------------------------------------+
+
+* **`sha2(<text>`) / `sha256(<text>)`**: Calculates an SHA-2 256-bit checksum for the string. (https://en.wikipedia.org/wiki/SHA-2) The value is returned as a string of hexadecimal digits, or NULL if the argument was NULL. Note that `sha2()` and `sha256()` are aliases for the same function.
+
+ select sha2( 'testing' ) from (VALUES(1));
+ +-------------------------------------------------------------------+
+ | EXPR$0 |
+ +-------------------------------------------------------------------+
+ | cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90 |
+ +-------------------------------------------------------------------+
+
+Additionally, there are also `sha384(<text>)` and `sha512(<text>)` functions which return SHA-2 hashes with 384 and 512 bit checksums.
\ No newline at end of file