在Hive

时间:2017-03-10 06:05:06

标签: hadoop hive

给出一个Hive表如下:

> desc T;
dim1 string
dim2 string
dim3 string
value1 int
value2 int

我正在尝试按群组(dim1, dim2, dim3)随机抽样1,000行。

解决方法是:

# bash
for dim1 in dim1_1, dim1_2; do
     for dim2 in dim2_1, dim2_2; do
        for dim3 in dim3_1, dim3_2; do
            hive -e "select * from T where dim1=$dim1 and dim2=$dim2 and dim3=$dim3 limit 1000;"
done done done

然后将连续执行2 ^ 3 = 8次查询。有没有更有效的方法?

1 个答案:

答案 0 :(得分:1)

 var webAddr = "http://localhost:3730/Safe2Pay.aspx";
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr);
            httpWebRequest.ContentType = "application/json; charset=utf-8";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                TestJason ddd = new TestJason();
                ddd.data1 = "Data1";
                ddd.data2 = "Data2";

                JavaScriptSerializer jsSeri = new JavaScriptSerializer();
                String sb = jsSeri.Serialize(ddd);

                streamWriter.Write(sb);
                streamWriter.Flush();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }