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
// Provide a single Environment Has clause: | |
// ZLayer[Orig, E, Has[From] with Rest] => ZLayer[Orig, E, Has[To] with Rest] | |
def projectionWithEffect[From: Tag, To: Tag, Rest <: Has[_]: Tag, E](effect: (From, Rest) => IO[E, To]): ZLayer[Has[From] with Rest, E, Has[To] with Rest] = | |
(for { | |
from <- ZIO.service[From] | |
rest <- ZIO.environment[Rest] | |
result <- effect(from, rest) | |
} yield Has(result) ++ rest).toLayerMany |
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
#!/bin/bash | |
group=$1 | |
artifact=$2 | |
version=$3 | |
# Diff like this: | |
# diff <(search_maven_gav.sh io.getquill 'quill-*_2.13' 3.6.0-RC2 | awk '{print $2}' | sort) <(search_maven_gav.sh io.getquill 'quill-*_2.13' 3.6.0-RC3 | awk '{print $2}' | sort) | |
curl -s "https://search.maven.org/solrsearch/select?rows=100&q=g:${group}+AND+a:${artifact}+AND+v:${version}" | jq --raw-output '.response.docs[] | [.g, .a, .v]|@tsv' |
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
case class Address(street: String, zip: Int, personName: String) | |
case class Person(name: String, addresses: List[String]) | |
/* | |
In some Data-Models used with Spark, you may want to embed arrays into an object. | |
You may then want to be able to set array-properties of this kind of object when | |
a group-by is done. Normally this would be done in Spark using the following way | |
*/ | |
val addresses: Dataset[Address] = ??? | |
val people = addresses.groupByKey(a => a.personName).mapGroups { case (name, addresses) => |
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
resolvers ++= Seq( | |
("OSS-Snapshots" at "https://oss.sonatype.org/service/local/repositories/snapshots/content/") | |
) | |
libraryDependencies ++= Seq( | |
"io.getquill" %% "quill-sql" % "3.5.3-SNAPSHOT", | |
) |
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 = { |
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
// ********** 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
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
// 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
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 | |
} | |
} |