Live data from Hacker News

I wrote a SQL engine in Python

github.com

11–20 of 81 posts

Re: I wrote a SQL engine in Python

#11
post #10

Python interpreter in SQL - the reverse of what was done - would've been really impressive. Terrible idea of course but impressive nonetheless.

A Python to SQL compiler already exists https://db.cs.uni-tuebingen.de/publications/2022/snakes-on-a...

I don't really compile python functions to sql -- I just execute sql. It's just that the execution engine is written in python

Re: I wrote a SQL engine in Python

#12
> A library to parse and optimize SQL,

That's like saying "a library to parse and optimize computer programs", except probably even harder, since a compiler and runtime library can't make any assumptions about the programs they need to make run, so they're limited in the potential of utilizing all that context information.

Countless person-years have been spent on this and it's still a very active fields of research and engineering.

> 2x SparkSQL performance

Ah, ok, so it can be slow. Never mind then, carry on :-P

Re: I wrote a SQL engine in Python

#13

> A library to parse and optimize SQL, That's like saying "a library to parse and optimize computer programs", except probably even harder, since a compiler and runtime library can't make any assumptions about the programs they need to make run, so they're limited in the potential of utilizing all that context information. Countless person-years have been spent on this and it's still a very active fields of research…

SQLGlot is really great, check it out!

Re: I wrote a SQL engine in Python

#17

> A library to parse and optimize SQL, That's like saying "a library to parse and optimize computer programs", except probably even harder, since a compiler and runtime library can't make any assumptions about the programs they need to make run, so they're limited in the potential of utilizing all that context information. Countless person-years have been spent on this and it's still a very active fields of research…

I'm the author of SQLGlot. Optimizing SQL is quite common and means things like projection / predicate push downs and logical simplification. SQL can be optimized relatively easily compared to a programming language because it is declarative. For example

SELECT * FROM (SELECT * FROM x) WHERE z = 1

can be optimized into

SELECT * FROM x where z = 1

Re: I wrote a SQL engine in Python

#20
post #16

Funnily enough I'm currently writing a NoSQL database in Python.

Why?

Most likely an autodidactic exercise. I'd love to see the source, even if, or especially if, it's half-finished. Seeing someone work their way through the snarls in such a project would be useful.
Post reply on HN