I'm working on Zeppelin and I want to see the describe of some tables in my databases but I can't see the comments of the columns, I used %sql and %livy.sql interpreter if that could help you for answering.
On the other side when I use Hive, I can see the comment of columns when I make the same request: describe table_name.
Have you ever encountered this type of problem? is this due to Zeppelin's setting?
Best regards,
The below code worked for me. You can try this too :)
%livy.spark
val hive_context = new org.apache.spark.sql.hive.HiveContext(sc)
hive_context.sql("desc your_db_name.your_table_name").show()
I can see the column name,data type and also the comment of columns as seen in hive :)
Related
SQL learner here, trying to make a join, but it seems to not work.
I have the following 2 tables:
#device_combined_players
#final_results2
The goal is to have a new table replacing the player_store_id from #final_results with the pseudo_name from #device_combined_players.
I have tried with:
SELECT #final_results2.player_store_id,
#device_combined_players.pseudo_name, #final_results2.genre FROM #device_combined_players INNER JOIN #final_results2 ON #final_results2.player_store_id = #device_combined_players.store_id
but I can't make it work, my output is simply an empty table.
Could you guys, please, give me some light? Thank you!
My expected result would be: as #final_results2 (image 2), but replacing player_store_id column by pseudo_name from #device_combined_players table.
EDIT: a screenshot with more details:
https://i.stack.imgur.com/lSyLb.png
And, I am answering myself, since I had 2 different issues here. Both are rookie mistakes, but I will leave them here so it helps somebody else in the future:
Take a look at the data type of your columns. They can cause conflicts if they are not the same as the columns you are referencing in a JOIN.
Check if your data doesn't have spaces. You can use TRIM and LEN to help you out answering this.
I sorted my problem like that.
I have a table with one column called name_of, I have a lot of duplicates in this table, I have some python code, that takes all the duplicates and then concat them into the SQL query. But I have tried for some time with no luck.
TableName = users_from_group
Column = name_of
i have tried the following sql query:
DELETE FROM users_from_group
WHERE name_of = ('AskeMeyer'), ('testuser'), ('AskeMeyer'), ('testuser'), ('testuser'), ('AskeMeyer')
and I don't understand why this is not working, as this is the format of data for querying adding into the table?
the best way to do this is:
DELETE FROM users_from_group
WHERE name_of IN ('AskeMeyer', 'testuser', 'AskeMeyer', 'testuser', 'testuser', 'AskeMeyer')
If this is useful for you, I would appreciate to mark as resolved.
Cheers
As #jarlh mentioned, you probably don't want to delete ALL of the records with these name_of's. I'm guessing you want to keep exactly 1 of each?
The best practice for this scenario is to do your work all in SQL, following a "Delete Duplicate Rows" pattern. There are a couple ways to do this, and it can matter which version of SQL you are using, but this question is a starting point.
Also, just a couple S/O tips:
Include which SQL server you are using in your questions in the future
Include the error message that you receive
i have some problems displaying my aws timestream data in grafana. I added as a global dashboard variable DevEUI with 3 different specific values. But when i am using the multivalue syntax ${DevEUI} in my query with more then one value i get everytime a error.
hope somebody can give me a hint.
Regards and thanks in advance
You are most probably having a list of values as the value of your multivalue Grafana variable, but you are still using the = operator in your query. Try ... and DevEUI IN ('${DevEUI}'). Or maybe without the single quotes or the parantheses... the exact syntax depends on your Grafana variable.
But, this is just an educated guess, since I cannot see neither your database schema nor the definition of this Grafana variable (both of which are important details in a question like yours, for future reference).
This is how I did it for a multivalued string value:
timestream_variable_name = ANY(VALUES ${grafana_variable_name:singlequote})
You might have to adjust the formatting Grafana applies to the concatenated variable value it generates, depending on your data type.
I know this is long after the original question but #alparius pointed me in the right direction so I wanted to update the fix for the problem Joe reported.
Use formatting to get the proper quotes/values when formatting your query. Something like this:
Select * from database where searchiterm IN (${Multi-Value_Variable:sqlstring})
Thanks in advance for taking a look into this, hope someone can help.
I am creating tables with fixed prefix + dynamic suffix
something like: name123456 in which name is fixed/static and 123456 is an incremental numeric value
I currently have multiple tables like:
name123456
name123457
name123458
And I am trying to dynamically query the most recent one (which is the one with the biggest suffix), in the given example it's "name123458".
When running the query below in the BigQuery UI:
#standardsql
select array_agg(distinct _TABLE_SUFFIX) from `project.dataset.name*`
I get no result, and (as far as I understand) I should get all the listed tables above.
I know to get the most recent one I need to use a WHERE clause with max(_TABLE_SUFFIX) but since I am getting an empty _TABLE_SUFFIX I can not get anything from it.
Let me know if more information is required and I'll update as needed.
I found the solution by myself so I'll share the solution here as an answer, but first, thanks to David and Martin Weitzmann for their time and help.
The problem with _TABLE_SUFFIX ignoring some tables/not returning something was that the tables I had in the dataset were all empty tables (just schema).
That's it, _TABLE_SUFFIX ignores empty tables, hope it helps someone else.
You can't use _TABLE_SUFFIX in your SELECT statement - only in the WHERE clause. But you can instead use metatables to find the most recent one: https://cloud.google.com/bigquery/docs/information-schema-tables
I need to get data in multiple row of one column.
For example data from that format
ID Interest
Sports
Cooking
Movie
Reading
to that format
ID Interest
Sports,Cooking
Movie,Reading
I wonder that we can do that in MS Access sql. If anybody knows that, please help me on that.
Take a look at Allen Browne's approach: Concatenate values from related records
As for the normalization argument, I'm not suggesting you store concatenated values. But if you want to join them together for display purposes (like a report or form), I don't think you're violating the rules of normalization.
This is called de-normalizing data. It may be acceptable for final reporting. Apparently some experts believe it's good for something, as seen here.
(Mind you, kevchadder's question is right on.)
Have you looked into the SQL Pivot operation?
Take a look at this link:
http://technet.microsoft.com/en-us/library/ms177410.aspx
Just noticed you're using access. Take a look at this article:
http://www.blueclaw-db.com/accessquerysql/pivot_query.htm
This is nothing you should do in SQL and it's most likely not possible at all.
Merging the rows in your application code shouldn't be too hard.