You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2022/02/11 07:09:17 UTC

[impala] branch master updated (97dda2b -> bde9954)

This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git.


    from 97dda2b  IMPALA-6636: Use async IO in ORC scanner
     new 677d4f9  IMPALA-11097: In test framework, call HS2 execute synchronously
     new bde9954  IMPALA-955: BYTES built-in function

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 be/src/exprs/expr-test.cc                                 |  8 ++++++++
 be/src/exprs/string-functions-ir.cc                       |  4 ++++
 be/src/exprs/string-functions.h                           |  1 +
 common/function-registry/impala_functions.py              |  1 +
 .../functional-query/queries/QueryTest/exprs.test         | 15 +++++++++++++++
 tests/common/impala_connection.py                         |  8 +++-----
 6 files changed, 32 insertions(+), 5 deletions(-)

[impala] 01/02: IMPALA-11097: In test framework, call HS2 execute synchronously

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 677d4f91a30e6f12d99b2422514c50d0bb7c799f
Author: Steve Carlin <sc...@cloudera.com>
AuthorDate: Fri Jan 7 08:50:02 2022 -0800

    IMPALA-11097: In test framework, call HS2 execute synchronously
    
    Changed the HS2 call to be synchronous. The previous code had a
    race condition because wait_to_finish needs to be called before
    checking the result set for Hive. Calling execute synchronously
    for HS2 ensures that the result set is ready.
    
    Change-Id: I5ab4b90ba2e1a439119d37fe9fb9c55eeeb53ba0
    Reviewed-on: http://gerrit.cloudera.org:8080/18133
    Reviewed-by: Csaba Ringhofer <cs...@cloudera.com>
    Tested-by: Csaba Ringhofer <cs...@cloudera.com>
---
 tests/common/impala_connection.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tests/common/impala_connection.py b/tests/common/impala_connection.py
index 07e172f..41280f7 100644
--- a/tests/common/impala_connection.py
+++ b/tests/common/impala_connection.py
@@ -335,7 +335,9 @@ class ImpylaHS2Connection(ImpalaConnection):
     operation_handle.get_handle().close_operation()
 
   def execute(self, sql_stmt, user=None, profile_format=TRuntimeProfileFormat.STRING):
-    handle = self.execute_async(sql_stmt, user)
+    self.__cursor.execute(sql_stmt, configuration=self.__query_options)
+    handle = OperationHandle(self.__cursor, sql_stmt)
+
     r = None
     try:
       r = self.__fetch_results(handle, profile_format=profile_format)
@@ -443,10 +445,6 @@ class ImpylaHS2Connection(ImpalaConnection):
         result_tuples = cursor.fetchall()
       else:
         result_tuples = cursor.fetchmany(max_rows)
-    elif self._is_hive:
-      # For Hive statements that have no result set (eg USE), they may still be
-      # running, and we need to wait for them to finish before we can proceed.
-      cursor._wait_to_finish()
 
     if not self._is_hive:
       log = self.get_log(handle)

[impala] 02/02: IMPALA-955: BYTES built-in function

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit bde995483a1b6e91dc5d089dfc07225a93d7c8ca
Author: pranav.lodha <pr...@cloudera.com>
AuthorDate: Thu Feb 3 10:04:51 2022 +0530

    IMPALA-955: BYTES built-in function
    
    The Bytes function returns the number of bytes contained
    in the specified byte string. There are changes in
    4 files. A few testcases are also added in
    be/src/exprs/expr-test.cc and an end-to end test in
    testdata/workloads/functional-query/queries/QueryTest/exprs.test.
    
    Change-Id: I0bd06c3d6dba354d71f63c649eaa8f9f74d266ee
    Reviewed-on: http://gerrit.cloudera.org:8080/18210
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exprs/expr-test.cc                                 |  8 ++++++++
 be/src/exprs/string-functions-ir.cc                       |  4 ++++
 be/src/exprs/string-functions.h                           |  1 +
 common/function-registry/impala_functions.py              |  1 +
 .../functional-query/queries/QueryTest/exprs.test         | 15 +++++++++++++++
 5 files changed, 29 insertions(+)

diff --git a/be/src/exprs/expr-test.cc b/be/src/exprs/expr-test.cc
index a7c0aa7..62b59ac 100644
--- a/be/src/exprs/expr-test.cc
+++ b/be/src/exprs/expr-test.cc
@@ -10705,6 +10705,14 @@ TEST_P(ExprTest, Utf8MaskTest) {
   executor_->PopExecOption();
 }
 
+TEST_P(ExprTest, BytesTest) {
+  // Verifies Bytes(exp) counts number of bytes.
+  TestIsNull("Bytes(NULL)", TYPE_INT);
+  TestValue("Bytes('你好')", TYPE_INT, 6);
+  TestValue("Bytes('你好hello')", TYPE_INT, 11);
+  TestValue("Bytes('你好 hello 你好')", TYPE_INT, 19);
+  TestValue("Bytes('hello')", TYPE_INT, 5);
+}
 TEST_P(ExprTest, Utf8Test) {
   // Verifies utf8_length() counts length by UTF-8 characters instead of bytes.
   // '你' and '好' are both encoded into 3 bytes.
diff --git a/be/src/exprs/string-functions-ir.cc b/be/src/exprs/string-functions-ir.cc
index 9e4dc7d..f8a1a61 100644
--- a/be/src/exprs/string-functions-ir.cc
+++ b/be/src/exprs/string-functions-ir.cc
@@ -258,6 +258,10 @@ IntVal StringFunctions::Length(FunctionContext* context, const StringVal& str) {
   }
   return IntVal(str.len);
 }
+IntVal StringFunctions::Bytes(FunctionContext* context,const StringVal& str){
+  if(str.is_null) return IntVal::null();
+  return IntVal(str.len);
+}
 
 IntVal StringFunctions::CharLength(FunctionContext* context, const StringVal& str) {
   if (str.is_null) return IntVal::null();
diff --git a/be/src/exprs/string-functions.h b/be/src/exprs/string-functions.h
index aa0544a..b9a2248 100644
--- a/be/src/exprs/string-functions.h
+++ b/be/src/exprs/string-functions.h
@@ -72,6 +72,7 @@ class StringFunctions {
       const StringVal& pad);
   static StringVal Rpad(FunctionContext*, const StringVal& str, const BigIntVal&,
       const StringVal& pad);
+  static IntVal Bytes(FunctionContext*, const StringVal& str);
   static IntVal Length(FunctionContext*, const StringVal& str);
   static IntVal CharLength(FunctionContext*, const StringVal& str);
   static IntVal Utf8Length(FunctionContext*, const StringVal& str);
diff --git a/common/function-registry/impala_functions.py b/common/function-registry/impala_functions.py
index dc01349..ee2a9a5 100644
--- a/common/function-registry/impala_functions.py
+++ b/common/function-registry/impala_functions.py
@@ -507,6 +507,7 @@ visible_functions = [
   [['repeat'], 'STRING', ['STRING', 'BIGINT'], 'impala::StringFunctions::Repeat'],
   [['lpad'], 'STRING', ['STRING', 'BIGINT', 'STRING'], 'impala::StringFunctions::Lpad'],
   [['rpad'], 'STRING', ['STRING', 'BIGINT', 'STRING'], 'impala::StringFunctions::Rpad'],
+  [['bytes'], 'INT', ['STRING'], 'impala::StringFunctions::Bytes'],
   [['length'], 'INT', ['STRING'], 'impala::StringFunctions::Length'],
   [['length'], 'INT', ['CHAR'], 'impala::StringFunctions::CharLength'],
   [['char_length'], 'INT', ['STRING'], 'impala::StringFunctions::Length'],
diff --git a/testdata/workloads/functional-query/queries/QueryTest/exprs.test b/testdata/workloads/functional-query/queries/QueryTest/exprs.test
index 0bb674a..cff4f15 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/exprs.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/exprs.test
@@ -3200,4 +3200,19 @@ select 'escape' like 'escap_'
 true
 ---- TYPES
 BOOLEAN
+====
+---- QUERY: IMPALA-955
+# Returns number of bytes in a byte string.
+select bytes(string_col), bytes(date_string_col) from functional.alltypestiny;
+---- RESULTS
+1,8
+1,8
+1,8
+1,8
+1,8
+1,8
+1,8
+1,8
+---- TYPES
+INT, INT
 ====
\ No newline at end of file