This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object CaseClassHListShapeQueryExample { | |
final class HListShape[Level <: ShapeLevel, M <: HList, U <: HList : ClassTag, P <: HList](val shapes: Seq[Shape[_, _, _, _]]) extends MappedScalaProductShape[Level, HList, M, U, P] { | |
def buildValue(elems: IndexedSeq[Any]) = elems.foldRight(HNil: HList)(_ :: _) | |
def copy(shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]) = new HListShape(shapes) | |
} | |
implicit def hnilShape[Level <: ShapeLevel] = new HListShape[Level, HNil.type, HNil.type, HNil.type](Nil) | |
implicit def hconsShape[Level <: ShapeLevel, M1, M2 <: HList, U1, U2 <: HList, P1, P2 <: HList](implicit s1: Shape[_ <: Level, M1, U1, P1], s2: HListShape[_ <: Level, M2, U2, P2]) = | |
new HListShape[Level, M1 :: M2, U1 :: U2, P1 :: P2](s1 +: s2.shapes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sample report base-class: | |
trait Report { | |
type T | |
def apply(runtimeConf:MyConf)(encoder:spark.sql.Encoder[T]):Unit | |
} | |
// Sample implementation: | |
class OrdersReport { | |
type T = OrderRecord | |
def runReport(runtimeConf:MyConf)(encoder:spark.sql.Encoder[OrderRecord]):Unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.getquill | |
import io.getquill.context.ContextEffect | |
import io.getquill.context.jdbc.JdbcContextBase | |
import io.getquill.context.sql.idiom.SqlIdiom | |
// Need this to be able to defined 'effect' since that's a package-private so this file needs to reside in the | |
// `io.getquill` package but it's the only thing that does. | |
trait JdbcContextBaseStub[Dialect <: SqlIdiom, Naming <: NamingStrategy] extends JdbcContextBase[Dialect, Naming] { | |
private[getquill] val effect: ContextEffect[Result] = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.getquill._ | |
import io.getquill.context.sql.norm._ | |
import io.getquill.norm.capture.AvoidCapture | |
import io.getquill.ast._ | |
import io.getquill.norm._ | |
import io.getquill.context.sql._ | |
import scala.annotation.tailrec | |
import io.getquill.context.sql.idiom.VerifySqlQuery | |
import io.getquill.norm.capture.DemarcateExternalAliases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def astEq[T <: io.getquill.ast.Ast](implicit tt: scala.reflect.runtime.universe.TypeTag[T]) = | |
new Equality[T] { | |
def areEqual(a: T, b: Any): Boolean = | |
b match { | |
case p: io.getquill.ast.Ast => p.neutralize == a.neutralize | |
case _ => false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When doing a query like this (this is in the unit tests) | |
val q = quote { | |
qr1.leftJoin(qr2).on { | |
(a, b) => | |
a.i == b.i | |
}.filter { | |
ab => { | |
val (a, b) = ab | |
b.map(bv => bv.l).contains(3L) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait FieldCollector[T] { | |
def collect(fields: Collector): Collector | |
} | |
object FieldCollector { | |
inline def collectFromChild[T](fields: ArrayBuffer[String]): Collector = | |
summonFrom { | |
case fc: FieldCollector[T] => fc.collect(fields) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ********** Before: ********** | |
// a.map(b => c).*join(d).on((iA, iB) => on) | |
// a.*join(d).on((b, iB) => on[iA := c]).map(t => (c[b := t._1], t._2)) | |
// Quat Equivalence: a.quat == b.quat == iA.quat | |
case Join(tpe, DetachableMap(a, b, c), d, iA, iB, on) => | |
val onr = BetaReduction(on, iA -> c) | |
val t = Ident("t") | |
val t1 = BetaReduction(c, b -> Property(t, "_1")) | |
val t2 = Property(t, "_2") | |
Some(Map(Join(tpe, a, d, b, iB, onr), t, Tuple(List(t1, t2)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Only runtime, only for Direct entity Types. Do not support things with generic parameters like Query[T] etc... | |
* This is needed because the quill-core/quill-sql JS use Scala JS which does not support TypeTags via the Dynamic Query API, | |
* (the Macro API is fine to use them). | |
*/ | |
object RuntimeEntityQuat { | |
def apply[T](implicit ct: ClassTag[T]): Quat = | |
forClassTopLevel(ct.runtimeClass) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.getquill.sql.norm | |
import io.getquill.ast._ | |
import io.getquill.ast.Implicits._ | |
import io.getquill.norm.BetaReduction | |
import io.getquill.norm.TypeBehavior.{ ReplaceWithReduction => RWR } | |
import io.getquill.norm.Normalize | |
import io.getquill.quat.Quat | |
// def nestedWithRenames(): Unit = { |
OlderNewer