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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Serge Smertin
June 30, 2022
Programming
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
500
Building robust Python applications on top of Databricks: UCX case study
nfx
0
430
Introducing the Power of Databricks SDK
nfx
0
560
Reaching 3M downloads and 90%+ unit test coverage for a Terraform provider: lessons learned
nfx
0
630
Distributed Data Mesh, Delta Lake, and Terraform
nfx
0
640
Data Quality with or without Apache Spark and its ecosystem
nfx
0
680
Data Privacy with Apache Spark: Defensive and Offensive Approaches
nfx
0
700
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
1
420
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
さぁV100、メモリをお食べ・・・
nilpe
0
160
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
190
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.3k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
210
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
Webフレームワークの ベンチマークについて
yusukebe
0
180
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
170
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
110
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
110
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
400
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
740
Game over? The fight for quality and originality in the time of robots
wayneb77
1
210
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
170
How GitHub (no longer) Works
holman
316
150k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Facilitating Awesome Meetings
lara
57
7k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
66
55k
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)})" }