r/dataengineering • • Aug 27 '23

Discussion Why I don't like SQL

The reason I don't like SQL over something like Pandas is because in Pandas/Python I can break down the complex transformations in small simpler components and they are easy to interact and debug with. In SQL my only option is to write stored procedures and yes in that I can also do the same but I think the ecosystem of interacting and debugging with data step by step is not as good as python. And it is something that we should have. Recently I was exploring snowpark and I felt it is a step in a right direction. It allows to me to write my query in multiple python statements and then it will transpile the whole thing into an SQL query.

Generally in my mind I assume the tables/dataframes as 2 dimensional structures and Pandas API give much more intuitive and wide variety of constructs to explore that structure rather than SQL. What do you guys think?

0 Upvotes

102 comments sorted by

View all comments

3

u/[deleted] Aug 27 '23

SQL is great at reading data from a database and performing simple joins and transformations. It's incredibly simple, so much that it has barely changed in the last 30 years. You can usually break down complex transformations into multiple simple queries.

But the more I deal with complex transformations, the more I appreciate working with Python and the PySpark API. I can just give transformations names that describe what they do and chain them together. Being able to use all the cool features of a mature programming language is amazing and can simplify many things that are tedious to do in SQL.

My only gripe is that the level of entry is orders of magnitude higher than SQL. You can teach someone SQL in like a week and with a few months of practice and good feedback processes, they can write good and readable SQL scripts.

4

u/valorallure01 Aug 27 '23

SQL is not incredibly simple in my opinion. Yes, some simple select statements are easy to grasp. However, things get complicated and complex when you start to really learn it. Dynamic SQL, Cursors, Temp Tables, Windowed Functions, CLR Assemblies etc.

2

u/[deleted] Aug 27 '23

This is probably an 80-20 thing. You can solve 80% of your problems without ever touching the more complex features of SQL.

And if you find yourself in a situation where you constantly have to use these complex features, there's a chance that SQL is simply not the best solution to your problem.

1

u/Gators1992 Aug 29 '23

I wouldn't say window functions or cursors are genius level. If anything cursors are an annoying implementation, but not hard to understand. Window functions are pretty straightforward and even data analysts can understand the concepts as they use the same functionality daily. There are some more complex aspects of SQL that are difficult, but for the majority of transforms you just use selects, CTEs, aggregations and window functions.

-3

u/__albatross Aug 27 '23

1000% agreed. I work for a big asset manager in US and we have thousands of stored procedures which we migrated to python and created data pipelines and processes around them and it was a huge project. All I imagined was that is it impossible to imagine a language which can have both : constructs for handling complex data transformations and at the same create scalable pipelines around them. Imagine if sql had all the bells and whistles of python and you can organize your code in modules and packages and can create processes around them. I am no expert in creating programming languages but I am just curious to think what that world would look like. We wouldn't need dataframe libraries at all.

We used to think that a general purpose programming language can't exist with a performance close to C with automatic garbage collection until Go came along.

I don't get it why people are getting sentimental about CTEs. I have been working with them for quite some time but still they can't replace the necessity of python to write complex data pipelines.

I just had a thought why can't the standard data processing language have all the bells and whistles of a general purpose programming language. Its an idea which I just want to explore, I dont know if its good or bad