Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Anatomy of a translating compiler
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Serge Smertin
June 30, 2022
Programming
580
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
540
Building robust Python applications on top of Databricks: UCX case study
nfx
0
470
Introducing the Power of Databricks SDK
nfx
0
600
Reaching 3M downloads and 90%+ unit test coverage for a Terraform provider: lessons learned
nfx
0
670
Distributed Data Mesh, Delta Lake, and Terraform
nfx
0
680
Data Quality with or without Apache Spark and its ecosystem
nfx
0
710
Data Privacy with Apache Spark: Defensive and Offensive Approaches
nfx
0
740
Other Decks in Programming
See All in Programming
AWSに止められる覚悟してますか?
morizo_1984
2
490
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
210
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
420
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
180
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
480
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
460
JRuby: Past, Present, and Future
headius
0
220
The Rails Doctrine Decade
koic
2
440
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
660
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
290
すこし踏み込む CancellationToken
htkym
2
1.5k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
4k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
960
It's Worth the Effort
3n
188
29k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
710
What's in a price? How to price your products and services
michaelherold
247
13k
Utilizing Notion as your number one productivity tool
mfonobong
4
610
Abbi's Birthday
coloredviolet
4
10k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
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)})" }