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
Serge Smertin
June 30, 2022
Programming
540
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
490
Building robust Python applications on top of Databricks: UCX case study
nfx
0
420
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
620
Distributed Data Mesh, Delta Lake, and Terraform
nfx
0
630
Data Quality with or without Apache Spark and its ecosystem
nfx
0
680
Data Privacy with Apache Spark: Defensive and Offensive Approaches
nfx
0
690
Other Decks in Programming
See All in Programming
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
120
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
190
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
200
OSもどきOS
arkw
0
480
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
160
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
A2UI という光を覗いてみる
satohjohn
1
120
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
120
Oxlintのカスタムルールの現況
syumai
6
1.1k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
250
スマートグラスで並列バイブコーディング
hyshu
0
120
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Building Applications with DynamoDB
mza
96
7.1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
850
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Embracing the Ebb and Flow
colly
88
5.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Designing for Timeless Needs
cassininazir
1
250
Into the Great Unknown - MozCon
thekraken
41
2.6k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
Become a Pro
speakerdeck
PRO
31
6k
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)})" }