I want a tool through which I can get the respective hive query by giving the PL/SQL query. There are lots of tools available which convert sql to hql. ie: taod for cloude database. But it does not show me the respective hive query.
Is there any such kind of tool whose convert given sql to hql. Please help me.
Thanks and Regards,
Ratan
Please take a look at open-source project PL/HQL at http://www.hplsql.org/ which is now a part of Hive 2.x or higher version. It allows you to run existing SQL Server, Oracle, Teradata, MySQL etc. stored procedures in Hive.
Ratan, I did not how to start responding. So, lets start like this. I think you checked toad and thinking like there is a tool to convert SQL to hive QL. I do not think there is such a tool.
Let me clarify like this, HIVE QL, is same as SQL. Check this links before you are trying to write some queries:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual,
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF.
This is simple to understand if you know sql and simple to write (as you check the HIve ql).
Hive doesnot have many operators the sql supports. For example:
select * from sales where country like 'EU~%'; "HIVE SUPPORTS LIKE"
But try this negative queries as we write in SQL :
select * from sales where country not like 'EU~%'; "HIVE DOES NOT SUPPORT"
This is just one example, I remember. There are more like this. But to deal with these hive has many like "where not" etc.
If your question is does the Hive have any PL/SQL support. Straight answer is no. But, we can check the UDF in hive and also, the PIG on Hadoop.
Related
I’m very fresh with database and R. At the moment, I would like to connect R with database(Hive) and use R as the tool to query data from source.
The problem is that we have multiple databases, but I just wanna connect the specific database to work around. How to do that in R? For now, i’m using USE statement to select specific database but it is not working.
My script is
Library(“DBI”)
Library(“RODBC”)
Conn<- odbcConnect(dsn=“Mydsn”)
Query<- “USE MY_SPECIFIC_DATABASE
SELECT*FROM MY_TABLE”
Res<-sqlQuery(Conn, Query)
I know we can select by [database].[table]. But I really appreciated if you have another way to solve this problem.
Also I cannot edit info in DSN cause no permission.
Please give me some advises to deal with this issue. Thank you
I'm working on some R-scripts which require the use of database queries. My IT department mentioned to me that these scripts require too much of the database (shared pool) and I should use bind-variables.
I am not very familiar with database designing, but I found out that bind variables are like variables i.e. if you use for example and date=:var in a statement.
Is it possible to use such statements when working with R (RODBC)?
Thank u very much
It seems that using bind variables is a part of the SQL query you write. So I presume that when you connect to the Oracle database using RODBC, you can pass an valid SQL query that contains bind variable syntax, and that this would simply work.
I started to use Flyway in my current project for database migrations and I like it very much. I currently use Oracle in PROD- and Derby in TEST-Environment.
Pretty soon, I did run in the problem of database specific sql commands, e.g.
ALTER TABLE T1 MODIFY F1 VARCHAR(256); on Oracle vs
ALTER TABLE T1 ALTER F1 SET DATA TYPE VARCHAR(256); on Derby.
I can't see a way to write a "vendor neutral alter table modify column datatype" sql.
What's the best way to deal with this problem using Flyway?
You can use the flyway.locations property.
In test in would look like this:
flyway.locations=sql/common,sql/derby
and in prod:
flyway.locations=sql/common,sql/oracle
You could then have the common statements (V1__Create_table.sql) in common and different copies of the DB-specific statements (V2__Alter_table.sql) in the db-specific locations.
An even better solution, in my opinion, is to have the same DB in prod and test. Yes, you do lose a bit of performance, but on the other hand you also eliminate another difference (and potential source of errors) between the environments.
The differences in SQL between Oracle and some of these desktop databases is minor. Is it possible for a developer to insert custom code to do some light-weight dynamic stripping of the SQL at runtime based on the environment (e.g. remove tablespace designation)?
I prefer this approach to relying on each developer to manually keep two sets of SQL in sync.
How can i make query to PL/SQL local collections like TABLE OF and VARRAY?
I searched the web , but whatever I found is to iterate over them eg. FOR LOOP!
Is there any facility to make query to them?
Thanks.
The SQL engine can make queries, the PL/SQL engine cannot. So you need to cast your collections to table types that are known to the SQL engine.
SQL doesn't know about types declared in packages, so you have to declare them at the global level.
Judging by your comment it seems like you pretty much figured it out already.
I know asp.net with mySQL is possible, but does it work well (fast and stable)? I am looking at a project for a client, they want to stay on mySQL, but they like they idea of going to asp.net from PHP. I can give them a better price by far in asp.net (more productive for me) and keep the project within their budget.
BUT, am I going to run into a whole lot of little 'gotchas' dealing with a mySQL DB instead of the SQl Server DB that I am used to?
Looking for advice from people who have actual done projects using these two together...either successfully, or unsuccessfully.
Seriously, man, I wouldnt try to over complicate it. Write the site just like you normally would, but using the MySQL data provider instead of the mssql provider. Keep it simple. Now there are some differences in how the two DBMSs handle their SQL.
Here are items that tripped me up originally.
MSSQL: SELECT TOP 5 * FROM Table
MySQL: SELECT * FROM TABLE LIMIT 0,5
MSSQL: SELECT IsNull(NumberField,0) FROM Table
MySQL: SELECT IfNull(NumberField,0) FROM TABLE
MySQL: Everything is CaSe-SenSiTivE
MySQL: Has stored procedures, but they are not as user friendly as MSSQL, so stick with inline sql.
MSSQL: select * from table where column1 = #col1 and column2 = #col2
MySQL: select * from table where column1 = ? and column2 = ? (remember to specify your command parameters in order)
There are a bunch of other little things that may complicate or confuse, but thats what this site is for, so you can ask
I would suggest using a tool like iBATIS.NET. It's a data mapping tool that works very well with .NET, and it's very easy to learn and is highly configurable.
You can configure multiple database providers (MySQL, SQL Server, Oracle, Sybase, etc.); almost everything is XML configurable, so SQL can be edited while your app is running, and if at some point they want to switch backend DBs, it's (sometimes) as easy as changing a couple of settings in an XML file.
Check it out: http://ibatis.apache.org/overview.html
There is a third option, MSSQL <-> SSIS/DTS <-> MySQL.
Both parties get to stay in their respective comfort zones, and you'll be more productive instead of tearing hair out working around gotchas.