# Looking for a ruby gem package to parse SQL query

**URL:** <https://www.ruby-forum.com/t/looking-for-a-ruby-gem-package-to-parse-sql-query/261827>\
**Category:** Uncategorized\
**Created:** [September 14, 2021, 3:02am UTC](https://www.ruby-forum.com/t/looking-for-a-ruby-gem-package-to-parse-sql-query/261827 "2021-09-14T03:02:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shinra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@Shinra](https://www.ruby-forum.com/u/Shinra)\
**Post date:** [September 14, 2021, 3:02am UTC](https://www.ruby-forum.com/t/looking-for-a-ruby-gem-package-to-parse-sql-query/261827/1 "2021-09-14T03:02:21Z")

</div>

Hi,

I’m new to Ruby language and I thought I could still do a simple task of normalizing + parsing SQL query using some third party library; but I had no luck finding any that works to my intention.

I’m using ruby for the ELK Logstash and therefore needs jRuby support.

Here’s what I’m trying to do:

Query like below

```auto
select 
     table_1.userId as col_0_0_ 
from tbUserTable table_1 
     where table_1.createdDate between '2021-05-23 00:00:00.0' and '2021-05-23 23:59:59.999' 
group by table_1.userId; 

```

will transform into JSON like below

```auto
{
"select": 
    {"value": "table_1.userId", "name": "col_0_0_"}, 
"from": 
     {
          "value": "tbUserTable",
          "name": "table_1"}, 
"where": {
          "between": ["table_1.createdDate", 0, 0]
}, 
"groupby": {"value": "table_1.userId"}
     }
}

```

**Also please note that the parameters inside WHERE condition has been normalized to 0, 0.**

If there is any Ruby Gem package that I could use on Logstash ruby filter that anybody’s aware of, I’d love to know!

Thanks in advance.
