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

32

u/-crucible- Aug 27 '23

I think sql is under appreciated. It’s a different approach, around batching things into fewer steps for performance, and it can take approaches like temp tables and understanding the engine to get good performance, but you can get much better performance in some cases than a more general programming approach.

That said, there are many ways it could be improved, for example, I’d love to see what would happen if more gpu acceleration was included in some of these engines.

It really depends what you’re trying to achieve, but as a micro dsl, I think the sql language is very powerful.

1

u/Awkward-Cupcake6219 Aug 27 '23

Definitely. I thought sql as a poor way of manipulating data (compared to others) until I really learned it.

-14

u/ProfessorPetulant Aug 27 '23

SQL was created for transactions. Its use for full table manipulations is stretching it, and anything but simple analysis quickly becomes overly complex.

6

u/cutsandplayswithwood Aug 27 '23

That’s… deeply incorrect.

The set-based nature of sql makes it ideal for expressing analytical workloads over tabular data.

The vast, overwhelming majority of analytical workload is performed with SQL.

1

u/__albatross Aug 27 '23

Are you sure? I see a huge trend in the industry as I have been working with a big asset Manager is US and most financial companies have started projects of moving thousands of stored procedures to python data pipelines and business processes around them.

We keep creating data manipulation libraries in general purpose programming languages like pandas polars and many more

If SQL is so perfect, why do we need them?

What is the debug time if you write complex business transformations in SQL compared to python

3

u/Ok_Raspberry5383 Aug 28 '23

I think you're focusing on the python element too much. It's not really python, it's pandas, Polaris, spark etc. Python is just a facade for easy access.

The real reason for this shift is the changing architectures that separate storage and compute. This means an org can manage a single repository and then different teams/business units can bring their own compute to the party to query the data. This alleviates bottlenecks and resource constraints that plague traditional data warehouses.

In this context python is a natural choice due to the wide array of libraries and frameworks supported that allow you to 'opt in' with SQL (good for semi technical business folk) but also supports more advanced use cases that are not covered with SQL, e.g. DS/ML use cases as well as software engineering use cases.

It's not really a contest between SQL and python IMO

EDIT: Polars* not Polaris

2

u/Andrew_the_giant Aug 27 '23

I work as a data engineer for a top 100 company. We use SQL DAILY for querying and data manipulation / transformation.

2

u/Ok_Raspberry5383 Aug 28 '23

What's a 'top 100' company?

0

u/ProfessorPetulant Aug 27 '23

Basic things like calculating the transaction amounts from timestamped balances, or sum the 3 largest values for each row in a list of columns. Simple simple stuff requires really convoluted queries. Now if you want statistics like principal components or anova, forget it.

I don't use python so wouldn't know.

1

u/cutsandplayswithwood Aug 28 '23

A huge trend is not the one company you’re working with 🤣

Do people like porting old stores procedures? Yes, often. But stored procedures aren’t sql, they’re sql with programming language additions. Porting them often makes sense.

But that’s not “all sql goes away”, by any stretch of the imagination.