Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.class
*.log
/target
/project
**/target
12 changes: 12 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 3.9.8
style = default
runner.dialect=scala212
maxColumn = 120
continuationIndent.defnSite = 2
continuationIndent.callSite = 2
align.preset = "none"
danglingParentheses.preset = true
optIn.configStyleArguments = false
docstrings.style = SpaceAsterisk
spaces.beforeContextBoundColon = true
rewrite.rules = [SortImports]
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Multi-dialect support for SQL parsing:
- Oracle SQL dialect
- PostgreSQL dialect
- ANSI SQL dialect
- CLI application (`Main.scala`) with comprehensive options:
- Multiple output formats: text, JSON, JQ queries
- File pattern matching (glob support)
- Configurable output destinations (console or file)
- Error recovery for unparseable statements
- Circe-based JSON encoding for all AST types
- Assembly plugin support for building standalone JARs
- Comprehensive test suite with Oracle-specific tests
- Support for parsing multiple statements from a single file with accurate line number tracking

### Changed
- **BREAKING**: Major refactoring of package structure:
- Moved core types to `sparsity.common.*` package
- Parser base classes now in `sparsity.common.parser.*`
- Statement types in `sparsity.common.statement.*`
- Expression types in `sparsity.common.expression.*`
- Refactored parser architecture:
- Moved logic from `Elements` into `SQLBase` for better subclass extensibility
- Created dialect-specific parser objects
- Enhanced build configuration:
- Updated SBT to 1.11.7
- Cross-compilation for Scala 2.12, 2.13, and 3.3
- Added assembly, scalafmt, and cross-project plugins
- Updated dependencies:
- fastparse to 3.1.1
- Added scribe for logging
- Added mainargs for CLI argument parsing
- Added monocle for optics
- Added java-jq for JQ query support

### Fixed
- Improved error messages with better context
- Better handling of parsing failures with fallback mechanisms

## [1.7.0] - Previous Release

### Added
- Cross-compiled support for Scala 2.12, 2.13, and 3.3
- Updated fastparse dependency

[Unreleased]: https://github.com/UBOdin/sparsity/compare/v1.7.0...HEAD
[1.7.0]: https://github.com/UBOdin/sparsity/releases/tag/v1.7.0
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ val tree = SQL("SELECT * FROM R")
libraryDependencies ++= Seq("info.mimirdb" %% "sparsity" % "1.5")
```


## Version History


#### 1.7 (Breaking)
- Added cross-compiled support for Scala 2.12
See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
134 changes: 97 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,49 +1,109 @@
import scala.sys.process._
import scala.scalanative.build._
import sbtcrossproject.CrossPlugin.autoImport._
import sbtassembly.AssemblyPlugin.autoImport._

name := "Sparsity"
version := "1.7.1-SNAPSHOT"
organization := "info.mimirdb"
scalaVersion := "2.12.20"
crossScalaVersions := Seq("2.12.20", "2.13.17", "3.3.6")
val Scala3 = "3.3.6"
val Scala2_13 = "2.13.17"
val Scala2_12 = "2.12.20"

dependencyOverrides ++= {
val circeVersion = "0.14.14"
val circeOpticsVersion = "0.15.1"
val jsonPathVersion = "0.2.0"
val specs2Version = "4.23.0"
val fastparseVersion = "3.1.1"
val javaJqVersion = "2.0.0"
val scribeVersion = "3.17.0"
val monocleVersion = "3.3.0"
val mainArgsVersion = "0.7.7"

ThisBuild / scalafmtOnCompile := true
ThisBuild / name := "Sparsity"
ThisBuild / version := "1.7.1-SNAPSHOT"
ThisBuild / organization := "info.mimirdb"
ThisBuild / scalaVersion := Scala2_13
ThisBuild / crossScalaVersions := Seq(Scala2_12, Scala2_13, Scala3)

ThisBuild / dependencyOverrides ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty // Scala 3 doesn't need override
case _ => Seq("org.scala-lang" % "scala-library" % scalaVersion.value)
}
}

resolvers += "MimirDB" at "https://maven.mimirdb.info/"
resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)
ThisBuild / resolvers += "MimirDB" at "https://maven.mimirdb.info/"
ThisBuild / resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

libraryDependencies ++= Seq(
"com.lihaoyi" %% "fastparse" % "3.1.1",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"ch.qos.logback" % "logback-classic" % "1.5.14",
"org.specs2" %% "specs2-core" % "4.23.0" % "test",
"org.specs2" %% "specs2-junit" % "4.23.0" % "test"
val scalacheckVersion = "1.19.0"

val commonSettings = Seq(
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "mainargs" % mainArgsVersion,
"com.lihaoyi" %%% "fastparse" % fastparseVersion,
"com.outr" %%% "scribe" % scribeVersion,
"io.circe" %%% "circe-core" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion,
"io.circe" %%% "circe-generic-extras" % "0.14.5-RC1",
"io.circe" %%% "circe-parser" % circeVersion,
"io.circe" %%% "circe-optics" % circeOpticsVersion,
"dev.optics" %% "monocle-core" % monocleVersion,
"dev.optics" %% "monocle-macro" % monocleVersion,
"com.quincyjo" %%% "scala-json-path-circe" % jsonPathVersion,
"com.arakelian" % "java-jq" % javaJqVersion,
"org.specs2" %%% "specs2-core" % specs2Version % "test",
"org.specs2" %%% "specs2-junit" % specs2Version % "test",
"org.scalacheck" %%% "scalacheck" % scalacheckVersion % "test"
)
)

////// Publishing Metadata //////
// use `sbt publish makePom` to generate
// a publishable jar artifact and its POM metadata

publishMavenStyle := true

pomExtra := <url>http://github.com/UBOdin/sparsity/</url>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:ubodin/sparsity.git</url>
<connection>scm:git:git@github.com:ubodin/sparsity.git</connection>
</scm>

/////// Publishing Options ////////
// use `sbt publish` to update the package in
// your own local ivy cache
publishTo := Some(Resolver.file("file", new File("/var/www/maven_repo/")))
val nativeSettings = Seq(
nativeConfig ~= {
_.withLTO(LTO.full)
.withMode(Mode.releaseFast)
.withGC(GC.commix)
}
)

// lazy val root = project
// .in(file("."))
// .aggregate(sparsity.jvm, sparsity.native)

lazy val sparsity =
//crossProject(JVMPlatform, NativePlatform)
//.crossType(CrossType.Pure)
project
.in(file("."))
.settings(
name := "Sparsity",
version := "1.7.1-SNAPSHOT",
organization := "info.mimirdb",
commonSettings,
// Assembly settings
assembly / mainClass := Some("sparsity.Main"),
assembly / assemblyJarName := s"${name.value}-${version.value}.jar",
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
},
assembly / artifact := {
val art = (assembly / artifact).value
art.withClassifier(Some("assembly"))
},
addArtifact(assembly / artifact, assembly),
// Publishing settings
publishMavenStyle := true,
pomExtra := <url>http://github.com/UBOdin/sparsity/</url>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:ubodin/sparsity.git</url>
<connection>scm:git:git@github.com:ubodin/sparsity.git</connection>
</scm>,
)
//.nativeSettings(nativeSettings)
.enablePlugins(AssemblyPlugin)
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.11.7
5 changes: 5 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.3")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.8")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")

Loading