Skip to content

Instantly share code, notes, and snippets.

@deusaquilus
deusaquilus / GetQueryWithoutVerification.scala
Created July 23, 2019 05:22
Get Back a Broken Quill SQL Query (i.e. Skip Query Verification)
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
@deusaquilus
deusaquilus / JdbcContextBaseStub.scala
Last active April 16, 2019 04:48
Quill Context Returning ResultSet/PreparedStatement
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
@deusaquilus
deusaquilus / Reports.scala
Created June 25, 2018 03:20
Type Member in Spark Report
// 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
@deusaquilus
deusaquilus / CaseClassHListShapeQueryExample.scala
Created November 20, 2016 16:21
Creating a CaseClassShape that uses HList therefore can have >22 Arity
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)