hiveql

How do we get the 1000 tables description using hive?

余生长醉 提交于 2019-12-02 04:42:49
I have 1000 tables, need to check the describe <table name>; for one by one. Instead of running one by one, can you please give me one command to fetch "N" number of tables in a single shot. You can make a shell script and call it with a parameter. For example following script receives schema, prepares list of tables in the schema, calls DESCRIBE EXTENDED command, extracts location, prints table location for first 1000 tables in the schema ordered by name. You can modify and use it as a single command: #!/bin/bash #Create table list for a schema (script parameter) HIVE_SCHEMA=$1 echo

Creating temp table from another table including partition column in hive

天涯浪子 提交于 2019-12-02 04:18:29
I am creating a temp table from another table using AS clause where I am including the partition column of another table also be part of temp table and then I am getting the below error. Below is the table create statement where col4 is the partition column of table xyz . And while running the create statement i am getting the below error. And when I am removing the col4 from the create statement its running fine. Error: Error while compiling statement: FAILED: NumberFormatException For input string: "HIVE_DEFAULT_PARTITION" (state=42000,code=40000) Please help. Example: CREATE TEMPORARY TABLE

Can hiveconf variables be loaded from a file? (Separate from the HiveQL file)

橙三吉。 提交于 2019-12-02 03:40:18
I often have a large block of HiveQL that I want to run multiple times with different settings for some variables. A simple example would be: set mindate='2015-01-01 00:00:00' set maxdate='2015-04-01 00:00:00' select * from my_table where the_date between ${hiveconf:mindate} and ${hiveconf:maxdate} Which is then run via hive -f myfile.sql > myout.log Later, I would like to change the variables and re-run. I also want a record of what values the variables had each time I ran. So I currently make copies of the HiveQL file that are the same except for the variable values. This is obviously error

override SemanticException [Error 10001]

删除回忆录丶 提交于 2019-12-02 03:35:52
I want to alter 1000s table in hive database, but some of their tables exits some doesn't. As I execute that .sql file, as soon as it found table not present, it exits from hive. so help me out to override or skip those queries whose table is not present in hive Try this configuration parameter: set hive.cli.errors.ignore=true; After setting it to 'true', all commands in the script are executed, no matter how many failed. See here: https://issues.apache.org/jira/browse/HIVE-1847 来源: https://stackoverflow.com/questions/48140266/override-semanticexception-error-10001

In hive,can we change location of managed/external table

Deadly 提交于 2019-12-02 03:18:53
In hive,can we change location of managed/external table if yes how. After changing location will it behave like external table or internal table Aryan Singh I tried to search this question but I didnt get a proper answer yes we can change the location of managed table if we add location CREATE TABLE weather (wban INT, date STRING, precip INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ LOCATION ‘ /hive/data/weather’; After creation we can change location by the below command ALTER (DATABASE|SCHEMA) database_name SET LOCATION hdfs_path Even if we change the location the table will behave as

Why do I get “File could only be replicated to 0 nodes” when writing to a partitioned table?

为君一笑 提交于 2019-12-02 03:12:41
I create an external table in Hive with partitions and then try to populate it from the existing table, however, I get the following exceptions: Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /apps/hive/warehouse/pavel.db/browserdatapart/.hive-staging_hive_2018-12-28_13-22-45_751_6056004898772238481-1/_task_tmp.-ext-10000/cityid=1/_tmp.000001_3 could only be replicated to 0 nodes instead of minReplication (=1). There are 1 datanode(s) running and no node(s) are excluded in this operation. at org.apache.hadoop.hdfs

SparkR from Rstudio - gives Error in invokeJava(isStatic = TRUE, className, methodName, …) :

限于喜欢 提交于 2019-12-02 02:54:49
I am using RStudio. After creating session if i try to create dataframe using R data it gives error. Sys.setenv(SPARK_HOME = "E:/spark-2.0.0-bin-hadoop2.7/spark-2.0.0-bin-hadoop2.7") Sys.setenv(HADOOP_HOME = "E:/winutils") .libPaths(c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib"), .libPaths())) Sys.setenv('SPARKR_SUBMIT_ARGS'='"sparkr-shell"') library(SparkR) sparkR.session(sparkConfig = list(spark.sql.warehouse.dir="C:/Temp")) localDF <- data.frame(name=c("John", "Smith", "Sarah"), age=c(19, 23, 18)) df <- createDataFrame(localDF) ERROR : Error in invokeJava(isStatic = TRUE, className,

NULL column names in Hive query result

陌路散爱 提交于 2019-12-02 00:48:37
I have downloaded the weather .txt files from NOAA , which looks like: WBAN,Date,Time,StationType,SkyCondition,SkyConditionFlag,Visibility,VisibilityFlag,WeatherType,WeatherTypeFlag,DryBulbFarenheit,DryBulbFarenheitFlag,DryBulbCelsius,DryBulbCelsiusFlag,WetBulbFarenheit,WetBulbFarenheitFlag,WetBulbCelsius,WetBulbCelsiusFlag,DewPointFarenheit,DewPointFarenheitFlag,DewPointCelsius,DewPointCelsiusFlag,RelativeHumidity,RelativeHumidityFlag,WindSpeed,WindSpeedFlag,WindDirection,WindDirectionFlag,ValueForWindCharacter,ValueForWindCharacterFlag,StationPressure,StationPressureFlag,PressureTendency

Converting columns to rows (UNPIVOT) in hiveql

风流意气都作罢 提交于 2019-12-02 00:31:16
问题 I have a table with a structure like this: column1, column2, column3, X1, X2, X3, X4 A1, A2, A3, 5, 6, 1, 4 I would like to convert this into column1, column2, column3, Key, Value A1, A2, A3, X1, 5 A1, A2, A3, X2, 6 A1, A2, A3, X3, 1 A1, A2, A3, X4 4 I was able to do this already using 4 queries stitched together with "UNION ALL", but since the table is huge and each select translates into a lengthy map-reduce, using UNION makes the query takes N times the time it should ideally take. Where N

How do the hive sql queries are submitted as mr job from hive cli

余生颓废 提交于 2019-12-01 21:12:36
I have deployed a CDH-5.9 cluster with MR as hive execution engine. I have a hive table named "users" with 50 rows. Whenever I execute the query select * from users works fine as follows : hive> select * from users; OK Adam 1 38 ATK093 CHEF Benjamin 2 24 ATK032 SERVANT Charles 3 45 ATK107 CASHIER Ivy 4 30 ATK384 SERVANT Linda 5 23 ATK132 ASSISTANT . . . Time taken: 0.059 seconds, Fetched: 50 row(s) But issuing select max(age) from users failed after submitting as mr job. The container log also doesn't have any information to figure it out why its getting failed. hive> select max(age) from