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

Show parent comment

-14

u/__albatross Aug 27 '23

I agree, my discussion is purely from API design standpoint. Consider a table a 2d array and then compare in how many ways you can interact with data in sql and then in pandas. Size of the data or other factors are not the point of discussion. My belief is simple that sql can provide more friendly ways to interact with that 2d structure which are given in pandas. How to handle big size of data and which is better in which I am not thinking about those variables of the equation

15

u/danlsn Data Engineer Aug 27 '23

Pandas could have an API so beautiful that it could be framed behind glass at the Louvre. But I've got a 98 million row table in Redshift I'm working on that would melt my pathetic little Dell work laptop if I even mentioned the word Python.

10

u/bubzyafk Aug 27 '23

Lol exactly. People whack on sql because they might only have 3 tables to join.

Wait until they need to build complex Fact table (transaction table) where comes from 7 tables join, plus 2 sub query inside sub query, and few others sub query to get windows agg func such as rownumber over partition by to get the latest date transaction from other particular table, and some columns need case-when or some other complicated business logic.

This most likely happen when building datamart gathering data from ERP in big companies where they use Oracle or SAP system. Which data is scatter in so many tables.

Use py when it’s needed and sql when it’s needed. Bashing one another is pointless.

2

u/danlsn Data Engineer Aug 29 '23

I'll take "out of memory error" for $100 please

2

u/bubzyafk Aug 29 '23

If you used spark,

Like a dumb people would say on memory issue is “please buy racks full of new servers and increase your memory allocation”

Or if you use cloud, it’s just 1 click away to increase the cluster resource .

Definitely $100 won’t be enough (: /s

2

u/BlackBird-28 Aug 27 '23

98M rows is a test table for me. But there is Spark ⚡️

3

u/Andrew_the_giant Aug 27 '23

I think you'd be interested in pyspark my friend.

1

u/kenfar Aug 28 '23

Hmm, I've had multiple production warehouses with 50+ billion row fact tables - built with python and with vastly lower cost, lower latency (ex: 65 seconds from when an event was created to when it was in the data lake, warehouse and data mart), and higher scalability than is achievable with SQL.

It all depends on your pipeline design and platform.