RSqLParser – software to parse your SQL queries.

[This article was first published on R – FordoX, and kindly contributed to R-bloggers]. (You may report concern concerning the content material on this web page right here)


Need to share your content material on R-bloggers? click on right here you probably have a weblog, or right here when you do not.

A gradual performing question is a ticking bomb which might result in explosion i.e an enormous efficiency overhead in your software, any time specifically when there’s load on database servers. And realizing the its and bits of your SQL question is of utmost significance in diffusing the bomb.

This isn’t the one state of affairs when realizing your SQL is essential. Out of your gradual question logs, you may need to discover probably the most used tables and time when a selected desk will get most hits to do some evaluation. This data most likely may help you resolve upon  a time so that you can take dumps or hearth alter queries on the desk.

Say for example, you’ve got a comparatively massive SQL question embedded in your software code which has most likely greater than tens of bind variables scattered right here and there. For debugging objective, you may need to exchange these variable along with your chosen values and hearth them in a selected SQL execution software which doesn’t assist dynamic bind variable alternative.

To cater to all of the wants, I felt there’s a want of SQL parser in R and got here up with this package deal – RSqlParser impressed by Java’s JSqlParser. This software will come helpful for finishing up many evaluation on SQL queries.

With this package deal, you’ll be able to design your free software to determine the explanations to your poorly performing queries or to handle your numerous different use instances.

RSqlParser is a non-validating SQL parser. It expects syntactically right SQL statements. It may be used to get numerous parts of SQL statements.

At the moment, it helps solely SELECT statements.

library(RSqlParser)

Strategies

There are at the moment four strategies within the package deal:

get_all_bind_variables: Get the bind variables in sql.
get_all_select_cols_with_alias: Get the names of the chosen columns within the sql
get_all_subqueries: Get the subqueries in sql.
get_all_tables_with_alias: Get the names of the tables with alias current in
the sql

There are various extra strategies ready to be launched in upcoming variations of the package deal. Not solely that, in upcoming variations, package deal ought to be capable of parse all DML and DDL statements.

Until then, if you’re dealing with any concern utilizing the package deal, please let me know.

To depart a remark for the writer, please observe the hyperlink and touch upon their weblog: R – FordoX.

R-bloggers.com presents each day e-mail updates about R information and tutorials about studying R and lots of different matters. Click on right here when you’re trying to submit or discover an R/data-science job.


Need to share your content material on R-bloggers? click on right here you probably have a weblog, or right here when you do not.

Leave a Reply

Your email address will not be published. Required fields are marked *