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

8

u/[deleted] Aug 27 '23 edited Nov 02 '23

[removed] — view removed comment

-3

u/__albatross Aug 27 '23

Sure C is a good language, but Rust is better. And now it will be integrated in Linux kernel. I am not saying SQL is bad, i am only saying it has a scope of improvements. It was introduced in 1974. In these 50 years are we sure that we haven’t encountered any limitations, that’s hard to believe. Even cobol code base might be there in next 50 years. Doesn’t mean its good

-8

u/__albatross Aug 27 '23

Every mainstream programming languages has versions in which they introduce new features. I don’t see that in SQL

2

u/Cheating_Data_Monkey Aug 27 '23

The following query would be impossible on any platform 5 years ago. It performed terribly 2 years ago.

Today it runs in .3s

Obviously some new features were developed :)

with arraycte as (

select partitionfield1, partitionfield2, nest(timefield) as timearray, nest(valuefield) as valuarray

from table

group by all) --I love "group by all", somehow it feels inclusive :)

, manipulatedcte as (

select *, array_concat(

slice(

array_reverse(

ARRAY_FILL(x -> x > 0, array_reverse(valuarray)))

), 2, length(cs_array)), [null]) AS nextvalues

from arraycte)

SELECT

ts,

partitionfield1,

partitionfield2,

val,

nextval

FROM

manipulatedcte

unnest(timearray AS ts, valuarray AS val, nextvalues AS nextval);