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
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
470
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
670
Other Decks in Programming
See All in Programming
My daily life on Ruby
a_matsuda
3
330
🦞OpenClaw works with AWS
licux
1
350
空間オーディオの活用
objectiveaudio
0
150
ハーネスエンジニアリングとは?
kinopeee
13
7k
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
150
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.7k
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
510
JCON - Create Agentic AI Apps, The Easy Way!
kdubois
1
110
SkillsをS3 Filesに置く時のあれこれ
watany
3
1.5k
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
cloudnative conference 2026 flyle
azihsoyn
0
180
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.9k
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Side Projects
sachag
455
43k
Designing Experiences People Love
moore
143
24k
Faster Mobile Websites
deanohume
310
31k
Designing for humans not robots
tammielis
254
26k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
390
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
ラッコキーワード サービス紹介資料
rakko
1
3.3M
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
240
How to train your dragon (web standard)
notwaldorf
97
6.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)})" }