Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Anatomy of a translating compiler
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Serge Smertin
June 30, 2022
Programming
520
0
Share
Anatomy of a translating compiler
How to build a programming language in Scala?
Serge Smertin
June 30, 2022
More Decks by Serge Smertin
See All by Serge Smertin
Building Databricks integrations with Go
nfx
0
480
Building robust Python applications on top of Databricks: UCX case study
nfx
0
410
Introducing the Power of Databricks SDK
nfx
0
550
Reaching 3M downloads and 90%+ unit test coverage for a Terraform provider: lessons learned
nfx
0
610
Distributed Data Mesh, Delta Lake, and Terraform
nfx
0
610
Data Quality with or without Apache Spark and its ecosystem
nfx
0
670
Data Privacy with Apache Spark: Defensive and Offensive Approaches
nfx
0
680
Other Decks in Programming
See All in Programming
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
13k
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
620
cloudnative conference 2026 flyle
azihsoyn
1
190
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
210
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
3
600
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
2k
Back to the roots of date
jinroq
0
880
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
190
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
210
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
100
[BalkanRuby 2026] Drop your app/services!
palkan
3
520
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
210
The Curious Case for Waylosing
cassininazir
1
350
Writing Fast Ruby
sferik
630
63k
Practical Orchestrator
shlominoach
191
11k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
200
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
150
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Statistics for Hackers
jakevdp
799
230k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Transcript
Anatomy of a translating compiler … or how to use
debugger all the time. 1 Serge Smertin Senior Resident Solutions Architect Databricks
None
Apache Spark query execution recap
4 code IN(4*, 5*)
5 code IN(4*, 5*)
6 code IN(4*, 5*)
7 SearchCommand( FieldIn("code", Seq( Wildcard("4*"), Wildcard("5*") )))
8 SearchCommand( FieldIn("code", Seq( Wildcard("4*"), Wildcard("5*") ))) Or( Like(UnresolvedAttribute("code"), Literal.create("4%"),
'\\'), Like(UnresolvedAttribute("code"), Literal.create("5%"), '\\'))
9 SearchCommand( FieldIn("code", Seq( Wildcard("4*"), Wildcard("5*") ))) Or( Like(UnresolvedAttribute("code"), Literal.create("4%"),
'\\'), Like(UnresolvedAttribute("code"), Literal.create("5%"), '\\')) private def expression(ctx: LogicalContext , expr: ast.Expr): Expression = expr match { case ast.FieldIn(field, exprs) if exprs.exists(_.isInstanceOf[ast.Wildcard]) => val expand = (expr: ast.Expr) => ast.Binary(ast.Field(field), ast.Equals, expr) expression(ctx, exprs.tail.foldLeft(expand(exprs.head)) { (left, right) => ast.Binary(left, ast.Or, expand(right)) }) case ast.FieldIn(field, exprs) => In(UnresolvedAttribute(field), exprs.map(expression(ctx, _))) case ast.Binary(left, ast.Equals, ast.Wildcard(pattern)) => like(ctx, left, pattern) case ast.Binary(left, symbol, right) => symbol match { case ast.Or => Or(attrOrExpr(ctx, left), attrOrExpr(ctx, right)) // ... } // ... }
10 SearchCommand( FieldIn("code", Seq( Wildcard("4*"), Wildcard("5*") ))) Or( Like(UnresolvedAttribute("code"), Literal.create("4%"),
'\\'), Like(UnresolvedAttribute("code"), Literal.create("5%"), '\\')) display(spark.table('main') .where((F.col('code').like('4%') | F.col('code').like('5%'))))
11 SearchCommand( FieldIn("code", Seq( Wildcard("4*"), Wildcard("5*") ))) Or( Like(UnresolvedAttribute("code"), Literal.create("4%"),
'\\'), Like(UnresolvedAttribute("code"), Literal.create("5%"), '\\')) display(spark.table('main') .where((F.col('code').like('4%') | F.col('code').like('5%')))) case relation: UnresolvedRelation => s"spark.table(${q(relation.name)})" private def unfoldWheres(expr: Expression): String = expr match { case And(left, right) => s"${unfoldWheres(left)}\n${unfoldWheres(right)}" case _ => s".where(${expressionCode(expr)})" } private def expressionCode(expr: Expression): String = expr match { case b: BinaryOperator => val symbol = jvmToPythonOverrides.getOrElse(b.symbol, b.symbol) s"(${expressionCode(b.left)} $symbol ${expressionCode(b.right)})" case attr: UnresolvedAttribute => s"F.col(${q(attr.name)})" case Like(col, Literal(value, _ @ StringType), _) => s"${expressionCode(col)}.like('$value')" case _ => s"F.expr(${q(expr.sql)})" }