---
title: "hive 内置函数"
author: "乡里伢崽"
date: "2014-08-11T09:06:07Z"
tags: []
categories: ["编程语言"]
slug: "hive"
draft: false
lastmod: "2014-08-11T09:31:31Z"
id: 2102290
url: "https://crazymatrix.iteye.com/blog/2102290"
---

1.sort_array():
sort_array(array(obj1, obj2,...)) - Sorts the input array in ascending order according to the natural ordering of the array elements.
Example:
  >SELECT sort_array(array('b', 'd', 'c', 'a')) FROM src LIMIT 1;
  'a', 'b', 'c', 'd'
2.ads():
abs(x) - returns the absolute value of x
Example:
  >SELECT abs(0) FROM src LIMIT 1;
  0
  >SELECT abs(-5) FROM src LIMIT 1;
  5
3,array_contains()
array_contains(array, value) - Returns TRUE if the array contains value.
Example:
  > SELECT array_contains(array(1, 2, 3), 2) FROM src LIMIT 1;
  true