I'm looking for a HIVE UDF that will parse an array of data into a tabular form.
If there's nothing in HIVE, a PIG example would be appreciated.
The input is in this format:
date timestamp key1="val1" key2="val2" key3="val3" year month day
date timestamp key1="val4" key2="val5" key3="val6" year month day
Would like the results to be a table where the column names are the keywords and the results are the values. Such as:
results:
column_name key1 key2 key3
results val1 val2 val3
val4 val5 val6
As of my understanding about your issue,i am pointing one solution.
first create a table in hive.
create table example1(dates string,timestamps string,key1 map<string,string>,key2 map<string,string>,key3 map<string,string>,year int, month string,day string) row format delimited fields terminated by ' ' map keys terminated by '=';
create another table like
create table example2(key1 string,key2 string,key3 string)
insert the data into second table from first table
insert into table example2 select key1["key1"],key2["key2"],key3["key3"] from example1;
output:
select * from example2;
"val1" "val2" "val3"
"val4" "val5" "val6"
in this, i am not concentrating on data types.
Related
Hello I Have a sheet with a list of names, medications, statuses and correlating dates on a spreadsheet. On a separate spreadsheet I would like to be able to type in a date and status (ex. "Pending", "active") and have the correlating patient names come up.
If i Type in 5/6/21 and then "active" I would like the formula to search the master-sheet and return names of patients whos status is "Active" after the Date 5/6/21.
I can't open your second sheet, but based on the first one, I've added a date input in cell F2.
Sheets QUERY is a powerful function that is similar to SQL. It can be used to display data from a dataset based on certain parameters (like your date search, and status = active).
In the example, the following QUERY formula goes in cell H1, but you can move it to a different tab if needed, obviously referencing 'DATA'!A:E etc.
=if(isblank(F2),,iferror(query(A:E,"where D > date '"&text(F2,"yyyy-mm-dd")&"' and lower(E) contains 'active' order by D,A",1),"No result"))
functions
isblank - if cell F2 is blank (the date search), then nothing.
iferror - if the query doesn't return any values, just output the wording 'No result'.
query function - as per the parameters below.
The range of your data is cells A:E.
The where clause basically says that the value in col D needs to be greater than the date within the single quotes '', which contains "&text(F2,"yyyy-mm-dd")&", which is the value of cell F2, formatted as text in the structure yyy-mmm-dd.
Placing "&<Sheets function>&" within the single quotes '' allows you to put another Sheets function in the query syntax, in this example the text function that formats the input of cell F2 as a date yyyy-mm-dd.
The where clause also includes an and where the lowercase of column E, lower(E) contains the word 'active'.
The results are ordered by column D then column A.
The ,1 at the end of the query tells it to treat the first row of data as headings. If it was data and not a heading, then it would be ,0.
Let me know if you need it implementing on your actual sheet.
I am trying to get the selective data from a Sheet.
I am getting Column U in comparision with Column P
Column U = Unique Data
Column P = Date and Time Associated with it.
Column U Column P
564865 2020-06-13 5:52:00
I would like to get the data of the day before current day while truncating time of Column P.
i am trying to use this query, but i am getting some error.
=QUERY('Shopify Unfulfilled'!1:2615,"Select U WHERE "&LEFT('Shopify Unfulfilled'!P:P,10)& "=" &TODAY()-1&"")
ERROR:
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <ID> "Created "" at line 1, column 16. Was expecting one of: "(" ... "(" ...
Thank you.
See if this works
=QUERY('Shopify Unfulfilled'!1:2615,"Select U WHERE todate (P) = date '"&TEXT(today() -1, "yyyy-MM-dd")&"'", 1)
I have a large set of data that's updated every 2 weeks, so I'm looking to simplify the solution.
Imported sheet has data from D6:G. The date is in Column B.
Right now, I insert column H and use
=ARRAYFORMULA(if(isblank(B6:B),"",datevalue(B6:B)))
In a new sheet, I import the data and order by Col H (the converted date) and Col G (the employee's name).
=query(TimeApr10!B6:H,"select B,C,D,E,F,G where H is not null order by H,G asc")
Is there a way to combine the two steps by converting Col B in the query to datevalue? If I don't convert the date, the ordering doesn't work.
I have a report which comes in a format which must be altered, several columns removed, filtered by category, etc.
Column G is a date 'YYYY-MM-DD' column, for my purposes I need to change the date cell to a string 'OOD' if the date is before today however I can't seem to figure out how I should try this.
I have attempted various combinations of array formula and substitute etc but all seem to break the query.
=QUERY('test data'!1:994,"select C,G,J,K,O where F='FOOD' and C is not null order by K asc",0)
try like this:
=ARRAYFORMULA(QUERY({'test data'!A1:F994,
IF('test data'!G1:G994<TODAY(), "OOD", 'test data'!G1:G994), 'test data'!H1:994},
"select Col3,Col7,Col10,Col11,Col15
where Col6='FOOD'
and Col3 is not null
order by Col11", 0))
Goal: Return a specific value from a table of data based on a query (kinda like if VLOOKUP provided the option for multiple criteria).
Problem: The data in the source table is a value and I can't change the data source's format. When I run my QUERY function I get #N/A. I know it's due to the data type of the source table data because when I update the format to "plain text" the value works.
Here is my Query:
=QUERY(SessionsData,"select D where B='"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
I know the logic works, watch this video for a brief demo.
How can I get this comparison to return results?
Adapted from this answer:
The Query language has two functions to help with date comparisons.
The todate() scalar function will convert spreadsheet dates (like your column B) to query date values. If the value started as a datetime, it returns just the date portion.
The date modifier treats specifically formatted strings as query date values.
Use them like so:
=QUERY(SessionsData,"select D where todate(B)=date '"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
^^^^^^^^^ ^^^^