You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ar...@apache.org on 2018/10/15 22:35:56 UTC

[1/4] impala git commit: IMPALA-5031: fix signed overflows in decimal

Repository: impala
Updated Branches:
  refs/heads/master af76186e0 -> fe6dabda6


IMPALA-5031: fix signed overflows in decimal

The standard says that overflow for signed arithmetic operations is
undefined behavior; see [expr]:

    If during the evaluation of an expression, the result is not
    mathematically defined or not in the range of representable values
    for its type, the behavior is undefined.

and [basic.fundamental]:

    Unsigned integers shall obey the laws of arithmetic modulo 2^n
    where n is the number of bits in the value representation of that
    particular size of integer. This implies that unsigned arithmetic
    does not overflow because a result that cannot be represented by
    the resulting unsigned integer type is reduced modulo the number
    that is one greater than the largest value that can be represented
    by the resulting unsigned integer type.

All of the overflows fixed in this patch were tested with expr-test's
DecimalArithmeticTest.

Change-Id: Ibf882428931e4f4264be2fc8cd9d6b1fc89b8ace
Reviewed-on: http://gerrit.cloudera.org:8080/11604
Reviewed-by: Jim Apple <jb...@apache.org>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/8fc702be
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/8fc702be
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/8fc702be

Branch: refs/heads/master
Commit: 8fc702be0c5017775e99fba0e88772ce3c14eb68
Parents: af76186
Author: Jim Apple <jb...@apache.org>
Authored: Fri Oct 5 16:04:56 2018 -0700
Committer: Impala Public Jenkins <im...@cloudera.com>
Committed: Sat Oct 13 06:23:17 2018 +0000

----------------------------------------------------------------------
 be/src/exprs/operators-ir.cc          |  21 +++---
 be/src/runtime/decimal-value.inline.h |   4 +-
 be/src/runtime/multi-precision.h      |  13 +++-
 be/src/util/arithmetic-util.h         | 115 +++++++++++++++++++++++++++++
 be/src/util/bit-util.h                |  70 ------------------
 be/src/util/decimal-util.h            |   9 ++-
 6 files changed, 145 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/exprs/operators-ir.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/operators-ir.cc b/be/src/exprs/operators-ir.cc
index a95cd7f..6ef8d50 100644
--- a/be/src/exprs/operators-ir.cc
+++ b/be/src/exprs/operators-ir.cc
@@ -17,6 +17,8 @@
 
 #include "exprs/operators.h"
 
+#include <functional>
+
 #include <boost/cstdint.hpp>
 
 #include "exprs/anyval-util.h"
@@ -48,14 +50,11 @@
 // of multiplication, addition, and subtraction are identical to the version of the signed
 // operation on a two's complement machine in which overflowing is not undefined, but
 // wraps.
-#define BINARY_OP_AS_UNSIGNED_FN(NAME, TYPE, OP)                                       \
-  TYPE Operators::NAME##_##TYPE##_##TYPE(                                              \
-      FunctionContext* c, const TYPE& v1, const TYPE& v2) {                            \
-    if (v1.is_null || v2.is_null) return TYPE::null();                                 \
-    using UNSIGNED = UnsignedType<decltype(TYPE::val)>;                                \
-    const UNSIGNED u1 = BitUtil::ToUnsigned(v1.val), u2 = BitUtil::ToUnsigned(v2.val); \
-    const UNSIGNED u0 = u1 OP u2;                                                      \
-    return TYPE(u0);                                                                   \
+#define BINARY_OP_AS_UNSIGNED_FN(NAME, TYPE, OP)                 \
+  TYPE Operators::NAME##_##TYPE##_##TYPE(                        \
+      FunctionContext* c, const TYPE& v1, const TYPE& v2) {      \
+    if (v1.is_null || v2.is_null) return TYPE::null();           \
+    return TYPE(ArithmeticUtil::AsUnsigned<OP>(v1.val, v2.val)); \
   }
 
 #define BINARY_OP_CHECK_ZERO_FN(NAME, TYPE, OP) \
@@ -191,9 +190,9 @@
 
 namespace impala {
 
-BINARY_OP_AS_UNSIGNED_TYPES(Add, +);
-BINARY_OP_AS_UNSIGNED_TYPES(Subtract, -);
-BINARY_OP_AS_UNSIGNED_TYPES(Multiply, *);
+BINARY_OP_AS_UNSIGNED_TYPES(Add, std::plus);
+BINARY_OP_AS_UNSIGNED_TYPES(Subtract, std::minus);
+BINARY_OP_AS_UNSIGNED_TYPES(Multiply, std::multiplies);
 
 BINARY_OP_FLOAT_TYPES(Add, +);
 BINARY_OP_FLOAT_TYPES(Subtract, -);

http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/runtime/decimal-value.inline.h
----------------------------------------------------------------------
diff --git a/be/src/runtime/decimal-value.inline.h b/be/src/runtime/decimal-value.inline.h
index 8b5f158..3150aef 100644
--- a/be/src/runtime/decimal-value.inline.h
+++ b/be/src/runtime/decimal-value.inline.h
@@ -21,6 +21,7 @@
 #include "runtime/decimal-value.h"
 
 #include <cmath>
+#include <functional>
 #include <iomanip>
 #include <limits>
 #include <ostream>
@@ -257,7 +258,8 @@ inline int128_t AddLarge(int128_t x, int x_scale, int128_t y, int y_scale,
       left > (DecimalUtil::MAX_UNSCALED_DECIMAL16 - right) / mult)) {
     *overflow = true;
   }
-  return DecimalUtil::SafeMultiply(left, mult, *overflow) + right;
+  return ArithmeticUtil::AsUnsigned<std::plus>(
+      DecimalUtil::SafeMultiply(left, mult, *overflow), right);
 }
 
 // Subtracts numbers that are large enough so that we can't subtract directly. Neither

http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/runtime/multi-precision.h
----------------------------------------------------------------------
diff --git a/be/src/runtime/multi-precision.h b/be/src/runtime/multi-precision.h
index c00cadb..0d8028f 100644
--- a/be/src/runtime/multi-precision.h
+++ b/be/src/runtime/multi-precision.h
@@ -46,8 +46,11 @@
 #include <boost/multiprecision/cpp_dec_float.hpp>
 #endif
 
+#include <functional>
 #include <limits>
 
+#include "util/arithmetic-util.h"
+
 namespace impala {
 
 /// We use the c++ int128_t type. This is stored using 16 bytes and very performant.
@@ -103,10 +106,12 @@ inline int128_t ConvertToInt128(int256_t x, int128_t max_value, bool* overflow)
     uint64_t v = (x % base).convert_to<uint64_t>();
     x /= base;
     *overflow |= (v > max_value / scale);
-    int128_t n = v * scale;
-    *overflow |= (result > max_value - n);
-    result += n;
-    scale *= base;
+    int128_t n =
+        ArithmeticUtil::AsUnsigned<std::multiplies>(static_cast<int128_t>(v), scale);
+    *overflow |= (result > ArithmeticUtil::AsUnsigned<std::minus>(max_value, n));
+    result = ArithmeticUtil::AsUnsigned<std::plus>(result, n);
+    scale =
+        ArithmeticUtil::AsUnsigned<std::multiplies>(scale, static_cast<int128_t>(base));
   }
   return negative ? -result : result;
 }

http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/util/arithmetic-util.h
----------------------------------------------------------------------
diff --git a/be/src/util/arithmetic-util.h b/be/src/util/arithmetic-util.h
new file mode 100644
index 0000000..93a0039
--- /dev/null
+++ b/be/src/util/arithmetic-util.h
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef IMPALA_ARITHMETIC_UTIL_H
+#define IMPALA_ARITHMETIC_UTIL_H
+
+#include <cstdint>
+#include <type_traits>
+
+namespace impala {
+
+// Nested 'type' corresponds to the unsigned version of T.
+template <typename T>
+struct MakeUnsigned {
+  using type = std::make_unsigned_t<T>;
+};
+
+template <>
+struct MakeUnsigned<__int128_t> {
+  using type = __uint128_t;
+};
+
+template <typename T>
+using UnsignedType = typename MakeUnsigned<T>::type;
+
+// Nested 'type' corresponds to the signed version of T.
+template <typename T>
+struct MakeSigned {
+  using type = std::make_signed_t<T>;
+};
+
+template <>
+struct MakeSigned<__uint128_t> {
+  using type = __int128_t;
+};
+
+template <typename T>
+using SignedType = typename MakeSigned<T>::type;
+
+class ArithmeticUtil {
+ private:
+  // There are times when it is useful to treat the bits in a signed integer as if they
+  // represent an unsigned integer, or vice versa. This is known as "type punning".
+  //
+  // For type punning signed values to unsigned values we can use the assurance in the
+  // standard's [conv.integral] to convert by simply returning the value: "A prvalue of an
+  // integer type can be converted to a prvalue of another integer type. ... If the
+  // destination type is unsigned, the resulting value is the least unsigned integer
+  // congruent to the source integer (modulo 2n where n is the number of bits used to
+  // represent the unsigned type). [Note: In a two's complement representation, this
+  // conversion is conceptual and there is no change in the bit pattern (if there is no
+  // truncation).]"
+  //
+  // For the other direction, the conversion is implementation-defined: "If the
+  // destination type is signed, the value is unchanged if it can be represented in the
+  // destination type (and bit-field width); otherwise, the value is
+  // implementation-defined."
+  //
+  // In GCC, the docs promise that when "[t]he result of, or the signal raised by,
+  // converting an integer to a signed integer type when the value cannot be represented
+  // in an object of that type ... For conversion to a type of width N, the value is
+  // reduced modulo 2^N to be within range of the type". As such, the same method of
+  // converting by simply returning works.
+  //
+  // Note that Clang does not document its implementation-defined behavior,
+  // https://bugs.llvm.org/show_bug.cgi?id=11272, so the static_asserts below are
+  // important
+  template <typename T>
+  constexpr static inline SignedType<T> ToSigned(T x) {
+    return x;
+  }
+
+  template <typename T>
+  constexpr static inline UnsignedType<T> ToUnsigned(T x) {
+    return x;
+  }
+
+  friend class ArithmeticUtilTest;
+
+ public:
+  // AsUnsigned can be used to perform arithmetic on signed integer types as if they were
+  // unsigned. Expected Use looks like "AsUnsigned<std::plus>(-1, 28)".
+  template <template <typename> class Operator, typename T>
+  static T AsUnsigned(T x, T y) {
+    const auto a = ToUnsigned(x), b = ToUnsigned(y);
+    return ToSigned(Operator<UnsignedType<T>>()(a, b));
+  }
+};
+
+class ArithmeticUtilTest {
+  static_assert(ArithmeticUtil::ToSigned<uint16_t>(0xffff) == -1
+          && ArithmeticUtil::ToSigned<uint16_t>(0x8000) == -0x8000,
+      "ToSigned is not a two's complement no-op");
+  static_assert(ArithmeticUtil::ToUnsigned<int16_t>(-1) == 0xffff
+          && ArithmeticUtil::ToUnsigned<int16_t>(-0x8000) == 0x8000,
+      "ToUnsigned is not a two's complement no-op");
+};
+
+} // namespace impala
+
+#endif // IMPALA_ARITHMETIC_UTIL_H

http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/util/bit-util.h
----------------------------------------------------------------------
diff --git a/be/src/util/bit-util.h b/be/src/util/bit-util.h
index 61b72b2..8e02611 100644
--- a/be/src/util/bit-util.h
+++ b/be/src/util/bit-util.h
@@ -38,34 +38,6 @@
 
 namespace impala {
 
-/// Nested 'type' corresponds to the unsigned version of T.
-template <typename T>
-struct MakeUnsigned {
-  using type = std::make_unsigned_t<T>;
-};
-
-template <>
-struct MakeUnsigned<int128_t> {
-  using type = __uint128_t;
-};
-
-template <typename T>
-using UnsignedType = typename MakeUnsigned<T>::type;
-
-/// Nested 'type' corresponds to the signed version of T.
-template <typename T>
-struct MakeSigned {
-  using type = std::make_signed_t<T>;
-};
-
-template <>
-struct MakeSigned<__uint128_t> {
-  using type = __int128_t;
-};
-
-template <typename T>
-using SignedType = typename MakeSigned<T>::type;
-
 // Doubles the width of integer types (e.g. int32_t -> int64_t).
 // Currently only works with a few signed types.
 // Feel free to extend it to other types as well.
@@ -420,50 +392,8 @@ class BitUtil {
       return floor + 1;
     }
   }
-
-  // There are times when it is useful to treat the bits in a signed integer as if they
-  // represent an unsigned integer, or vice versa. This is known as "type punning".
-  //
-  // For type punning signed values to unsigned values we can use the assurance in the
-  // standard's [conv.integral] to convert by simply returning the value: "A prvalue of an
-  // integer type can be converted to a prvalue of another integer type. ... If the
-  // destination type is unsigned, the resulting value is the least unsigned integer
-  // congruent to the source integer (modulo 2n where n is the number of bits used to
-  // represent the unsigned type). [Note: In a two's complement representation, this
-  // conversion is conceptual and there is no change in the bit pattern (if there is no
-  // truncation).]"
-  //
-  // For the other direction, the conversion is implementation-defined: "If the
-  // destination type is signed, the value is unchanged if it can be represented in the
-  // destination type (and bit-field width); otherwise, the value is
-  // implementation-defined."
-  //
-  // In GCC, the docs promise that when "[t]he result of, or the signal raised by,
-  // converting an integer to a signed integer type when the value cannot be represented
-  // in an object of that type ... For conversion to a type of width N, the value is
-  // reduced modulo 2^N to be within range of the type". As such, the same method of
-  // converting by simply returning works.
-  //
-  // Note that Clang does not document its implementation-defined behavior,
-  // https://bugs.llvm.org/show_bug.cgi?id=11272, so the static_asserts below are
-  // important
-  template <typename T>
-  constexpr static inline SignedType<T> ToSigned(T x) {
-    return x;
-  }
-  template <typename T>
-  constexpr static inline UnsignedType<T> ToUnsigned(T x) {
-    return x;
-  }
 };
 
-static_assert(BitUtil::ToSigned<uint16_t>(0xffff) == -1
-        && BitUtil::ToSigned<uint16_t>(0x8000) == -0x8000,
-    "ToSigned is not a two's complement no-op");
-static_assert(BitUtil::ToUnsigned<int16_t>(-1) == 0xffff
-        && BitUtil::ToUnsigned<int16_t>(-0x8000) == 0x8000,
-    "ToUnsigned is not a two's complement no-op");
-
 template<>
 inline int256_t BitUtil::Sign(int256_t value) {
   return value < 0 ? -1 : 1;

http://git-wip-us.apache.org/repos/asf/impala/blob/8fc702be/be/src/util/decimal-util.h
----------------------------------------------------------------------
diff --git a/be/src/util/decimal-util.h b/be/src/util/decimal-util.h
index 53cedb1..5b79a4b 100644
--- a/be/src/util/decimal-util.h
+++ b/be/src/util/decimal-util.h
@@ -19,6 +19,7 @@
 #ifndef IMPALA_UTIL_DECIMAL_UTIL_H
 #define IMPALA_UTIL_DECIMAL_UTIL_H
 
+#include <functional>
 #include <ostream>
 #include <string>
 #include <boost/cstdint.hpp>
@@ -46,7 +47,13 @@ class DecimalUtil {
   // if may_overflow is false.
   template <typename T>
   static T SafeMultiply(T a, T b, bool may_overflow) {
-    T result = a * b;
+    T result = ArithmeticUtil::AsUnsigned<std::multiplies>(a, b);
+    DCHECK(may_overflow || a == 0 || result / a == b);
+    return result;
+  }
+
+  static int256_t SafeMultiply(int256_t a, int256_t b, bool may_overflow) {
+    int256_t result = a * b;
     DCHECK(may_overflow || a == 0 || result / a == b);
     return result;
   }


[4/4] impala git commit: IMPALA-7706: [DOCS] Added the privileges required for ALTER TABLE SET OWNER

Posted by ar...@apache.org.
IMPALA-7706: [DOCS] Added the privileges required for ALTER TABLE SET OWNER

Also, added the privileges required for ALTER VIEW SET OWNER

Change-Id: I671dbe3e6fb3118a67c59fb1fcaf1ec53139b587
Reviewed-on: http://gerrit.cloudera.org:8080/11675
Reviewed-by: Fredy Wijaya <fw...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/fe6dabda
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/fe6dabda
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/fe6dabda

Branch: refs/heads/master
Commit: fe6dabda6a55dcd6f047829012a5f9ebf0755df3
Parents: 1bfd7ee
Author: Alex Rodoni <ar...@cloudera.com>
Authored: Fri Oct 12 16:49:40 2018 -0700
Committer: Alex Rodoni <ar...@cloudera.com>
Committed: Mon Oct 15 21:51:12 2018 +0000

----------------------------------------------------------------------
 docs/shared/impala_common.xml | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/fe6dabda/docs/shared/impala_common.xml
----------------------------------------------------------------------
diff --git a/docs/shared/impala_common.xml b/docs/shared/impala_common.xml
index 45b7d87..847bc9a 100644
--- a/docs/shared/impala_common.xml
+++ b/docs/shared/impala_common.xml
@@ -127,6 +127,8 @@ under the License.
               <codeph>INSERT</codeph>, <codeph>CREATE</codeph>,
               <codeph>ALTER</codeph>, <codeph>DROP</codeph>, <b><i>and</i></b>
             <codeph>REFRESH</codeph> privileges.</li>
+          <li>The owner of an object effectively has the ALL privilege on the
+            object.</li>
           <li>The parent levels of the specified scope are implicitly supported
             where a scope refers to the specific level in the object hierarchy
             that the privilege is granted. For example, if a privilege is listed
@@ -266,8 +268,8 @@ under the License.
                 <entry>TABLE</entry>
               </row>
               <row>
-                <entry>ALTER DATABASE</entry>
-                <entry>ALTER</entry>
+                <entry>ALTER DATABASE SET OWNER</entry>
+                <entry>ALL WITH GRANT</entry>
                 <entry>DATABASE</entry>
               </row>
               <row>
@@ -296,6 +298,11 @@ under the License.
                 <entry>TABLE</entry>
               </row>
               <row>
+                <entry>ALTER TABLE SET OWNER</entry>
+                <entry>ALL WITH GRANT</entry>
+                <entry>TABLE</entry>
+              </row>
+              <row>
                 <entry>ALTER VIEW</entry>
                 <entry>ALTER</entry>
                 <entry>TABLE</entry>
@@ -316,6 +323,11 @@ under the License.
                 <entry>TABLE</entry>
               </row>
               <row>
+                <entry>ALTER VIEW SET OWNER</entry>
+                <entry>ALL WITH GRANT</entry>
+                <entry>VIEW</entry>
+              </row>
+              <row>
                 <entry>DROP DATABASE</entry>
                 <entry>DROP</entry>
                 <entry>DATABASE</entry>


[2/4] impala git commit: IMPALA-7703: Update to Sentry 2.1.0

Posted by ar...@apache.org.
IMPALA-7703: Update to Sentry 2.1.0

This patch bumps the CDH_BUILD_NUMBER to 632827 in order to use Sentry
2.1.0.

Testing:
- Ran all core tests

Change-Id: I001d17313663171bc6ff23d62026c258486726a1
Reviewed-on: http://gerrit.cloudera.org:8080/11678
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/9571b18c
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/9571b18c
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/9571b18c

Branch: refs/heads/master
Commit: 9571b18ca4ad197eee1bb43092f05722de4c8ee5
Parents: 8fc702b
Author: Fredy Wijaya <fw...@cloudera.com>
Authored: Fri Oct 12 19:39:53 2018 -0700
Committer: Impala Public Jenkins <im...@cloudera.com>
Committed: Sat Oct 13 19:02:14 2018 +0000

----------------------------------------------------------------------
 bin/impala-config.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/9571b18c/bin/impala-config.sh
----------------------------------------------------------------------
diff --git a/bin/impala-config.sh b/bin/impala-config.sh
index 02e2eeb..9f8408c 100755
--- a/bin/impala-config.sh
+++ b/bin/impala-config.sh
@@ -158,11 +158,11 @@ fi
 : ${CDH_DOWNLOAD_HOST:=native-toolchain.s3.amazonaws.com}
 export CDH_DOWNLOAD_HOST
 export CDH_MAJOR_VERSION=6
-export CDH_BUILD_NUMBER=618371
+export CDH_BUILD_NUMBER=632827
 export IMPALA_HADOOP_VERSION=3.0.0-cdh6.x-SNAPSHOT
 export IMPALA_HBASE_VERSION=2.1.0-cdh6.x-SNAPSHOT
 export IMPALA_HIVE_VERSION=2.1.1-cdh6.x-SNAPSHOT
-export IMPALA_SENTRY_VERSION=2.0.0-cdh6.x-SNAPSHOT
+export IMPALA_SENTRY_VERSION=2.1.0-cdh6.x-SNAPSHOT
 export IMPALA_PARQUET_VERSION=1.9.0-cdh6.x-SNAPSHOT
 export IMPALA_AVRO_JAVA_VERSION=1.8.2-cdh6.x-SNAPSHOT
 export IMPALA_LLAMA_MINIKDC_VERSION=1.0.0


[3/4] impala git commit: IMPALA-7705: [DOCS] Documented the ALTER DATABASE SET OWNER statement

Posted by ar...@apache.org.
IMPALA-7705: [DOCS] Documented the ALTER DATABASE SET OWNER statement

Change-Id: Ifac0b689d55f525145b37846967a7a22f0e9245b
Reviewed-on: http://gerrit.cloudera.org:8080/11674
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Adam Holley <ah...@cloudera.com>
Reviewed-by: Fredy Wijaya <fw...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/1bfd7ee1
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/1bfd7ee1
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/1bfd7ee1

Branch: refs/heads/master
Commit: 1bfd7ee1c6315cc38126ed81dd757f56e01c5b16
Parents: 9571b18
Author: Alex Rodoni <ar...@cloudera.com>
Authored: Fri Oct 12 16:05:53 2018 -0700
Committer: Alex Rodoni <ar...@cloudera.com>
Committed: Mon Oct 15 19:35:51 2018 +0000

----------------------------------------------------------------------
 docs/impala.ditamap                   |  1 +
 docs/topics/impala_adls.xml           | 16 +++---
 docs/topics/impala_alter_database.xml | 79 ++++++++++++++++++++++++++++++
 docs/topics/impala_databases.xml      |  9 ++--
 4 files changed, 93 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/impala/blob/1bfd7ee1/docs/impala.ditamap
----------------------------------------------------------------------
diff --git a/docs/impala.ditamap b/docs/impala.ditamap
index 213d2c9..373b92d 100644
--- a/docs/impala.ditamap
+++ b/docs/impala.ditamap
@@ -129,6 +129,7 @@ under the License.
     <topicref href="topics/impala_langref_sql.xml">
       <topicref href="topics/impala_ddl.xml"/>
       <topicref href="topics/impala_dml.xml"/>
+      <topicref href="topics/impala_alter_database.xml"/>
       <topicref href="topics/impala_alter_table.xml"/>
       <topicref href="topics/impala_alter_view.xml"/>
       <topicref href="topics/impala_comment.xml"/>

http://git-wip-us.apache.org/repos/asf/impala/blob/1bfd7ee1/docs/topics/impala_adls.xml
----------------------------------------------------------------------
diff --git a/docs/topics/impala_adls.xml b/docs/topics/impala_adls.xml
index a02525a..5d790c5 100644
--- a/docs/topics/impala_adls.xml
+++ b/docs/topics/impala_adls.xml
@@ -359,14 +359,14 @@ adl://<varname>your_account</varname>.azuredatalakestore.net/<varname>rest_of_di
         and tables are created.
       </p>
 
-      <p>
-        You can switch whether an existing table or partition points to data in HDFS or ADLS. For example, if you
-        have an Impala table or partition pointing to data files in HDFS or ADLS, and you later transfer those data
-        files to the other filesystem, use an <codeph>ALTER TABLE</codeph> statement to adjust the
-        <codeph>LOCATION</codeph> attribute of the corresponding table or partition to reflect that change. Because
-        Impala does not have an <codeph>ALTER DATABASE</codeph> statement, this location-switching technique is not
-        practical for entire databases that have a custom <codeph>LOCATION</codeph> attribute.
-      </p>
+      <p> You can switch whether an existing table or partition points to data
+        in HDFS or ADLS. For example, if you have an Impala table or partition
+        pointing to data files in HDFS or ADLS, and you later transfer those
+        data files to the other filesystem, use an <codeph>ALTER TABLE</codeph>
+        statement to adjust the <codeph>LOCATION</codeph> attribute of the
+        corresponding table or partition to reflect that change. This
+        location-switching technique is not practical for entire databases that
+        have a custom <codeph>LOCATION</codeph> attribute. </p>
 
     </conbody>
 

http://git-wip-us.apache.org/repos/asf/impala/blob/1bfd7ee1/docs/topics/impala_alter_database.xml
----------------------------------------------------------------------
diff --git a/docs/topics/impala_alter_database.xml b/docs/topics/impala_alter_database.xml
new file mode 100644
index 0000000..a768346
--- /dev/null
+++ b/docs/topics/impala_alter_database.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
+<concept rev="3.1 IMPALA-7016" id="alter_database">
+
+  <title>ALTER DATABASE Statement</title>
+
+  <titlealts audience="PDF">
+
+    <navtitle>ALTER DATABASE</navtitle>
+
+  </titlealts>
+
+  <prolog>
+    <metadata>
+      <data name="Category" value="Impala"/>
+      <data name="Category" value="SQL"/>
+      <data name="Category" value="DDL"/>
+      <data name="Category" value="Databases"/>
+      <data name="Category" value="Schemas"/>
+      <data name="Category" value="Developers"/>
+      <data name="Category" value="Data Analysts"/>
+    </metadata>
+  </prolog>
+
+  <conbody>
+
+    <p>
+      The <codeph>ALTER DATABASE</codeph> statement changes the characteristics of a database.
+    </p>
+
+    <p>
+      Use the <codeph>SET OWNER</codeph> clause to transfer the ownership of the database from
+      the current owner to another user or a role.
+    </p>
+
+    <p>
+      The database owner is originally set to the user who creates the database. An owner of a
+      database has the <codeph>ALL</codeph> privilege, but the term <codeph>OWNER</codeph> is
+      used to differentiate between the <codeph>ALL</codeph> privilege that is explicitly
+      granted via the <codeph>GRANT</codeph> statement and a privilege that is implicitly
+      granted by the <codeph>CREATE DATABASE</codeph> statement.
+    </p>
+
+    <p conref="../shared/impala_common.xml#common/syntax_blurb"/>
+
+<codeblock>
+ALTER DATABASE <varname>database_name</varname> SET OWNER USER user_name;
+ALTER DATABASE <varname>database_name</varname> SET OWNER ROLE role_name;
+</codeblock>
+
+    <p conref="../shared/impala_common.xml#common/ddl_blurb"/>
+
+    <p conref="../shared/impala_common.xml#common/cancel_blurb_no"/>
+
+    <p>
+      <b>Added in:</b> <keyword keyref="impala31_full"/>
+    </p>
+
+  </conbody>
+
+</concept>

http://git-wip-us.apache.org/repos/asf/impala/blob/1bfd7ee1/docs/topics/impala_databases.xml
----------------------------------------------------------------------
diff --git a/docs/topics/impala_databases.xml b/docs/topics/impala_databases.xml
index 3834cba..d1fd417 100644
--- a/docs/topics/impala_databases.xml
+++ b/docs/topics/impala_databases.xml
@@ -42,10 +42,11 @@ under the License.
       databases can contain tables with identical names.
     </p>
 
-    <p>
-      Creating a database is a lightweight operation. There are minimal database-specific properties to configure,
-      only <codeph>LOCATION</codeph> and <codeph>COMMENT</codeph>.  There is no <codeph>ALTER DATABASE</codeph> statement.
-    </p>
+    <p> Creating a database is a lightweight operation. There are minimal
+      database-specific properties to configure, such as
+        <codeph>LOCATION</codeph> and <codeph>COMMENT</codeph>. </p>
+    <p>You can change the owner of a database with the <codeph>ALTER
+        DATABASE</codeph> statement. </p>
 
     <p>
       Typically, you create a separate database for each project or application, to avoid naming conflicts between