Skip to content
Merged
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [0.8.1]

### Breaking changes
- Filter queries (`DataFrame.select(String)`, `FilterPredicate.compile(String)`) are now parsed by the [query-compiler](https://github.com/nRo/query-compiler) library
(`dev.gruen:query-compiler`) instead of the built-in ANTLR grammar. The ANTLR grammar, the generated parser and the visitors were removed.
Changes in the query syntax:
- Logical operators have a precedence now: `AND` binds stronger than `XOR`, which binds stronger than `OR` / `NOR` (left-associative). Before, all logical operators were evaluated from left to right with equal precedence. Use brackets to keep the old evaluation order.
- Boolean column flags (`flag`, `!flag`) are no longer supported. Use `flag == true` / `flag == false`.
- A query that is a single word is parsed as full-text search, which is not supported by DataFrame, and raises a `PredicateCompilerException`.
- Decimal numbers with a comma (`1,5`) are no longer supported because `,` separates the values of `in (..)` lists. Use `1.5`.

### Added
- Filter queries support `in (1, 2)`, `!in (1, 2)` and `*=` (contains) operators.

## [0.8.0]

### Breaking changes
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
An easy-to-use DataFrame Library for Java.


[![CI](https://github.com/nRo/DataFrame/actions/workflows/ci.yml/badge.svg)](https://github.com/nRo/DataFrame/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/nRo/DataFrame/branch/master/graph/badge.svg)](https://codecov.io/gh/nRo/DataFrame)
[![CI](https://github.com/nRo/dataframe/actions/workflows/ci.yml/badge.svg)](https://github.com/nRo/dataframe/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/nRo/dataframe/branch/master/graph/badge.svg)](https://codecov.io/gh/nRo/dataframe)
[![Maven Central](https://img.shields.io/maven-central/v/dev.gruen/dataframe.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/dev.gruen/dataframe)
[![Javadocs](https://javadoc.io/badge2/dev.gruen/dataframe/javadoc.svg)](https://javadoc.io/doc/dev.gruen/dataframe)
![Java 21+](https://img.shields.io/badge/Java-21%2B-blue)
Expand Down Expand Up @@ -41,7 +41,7 @@ To build the library from sources you need JDK 21+ and Maven 3.9+:

1) Clone github repository

$ git clone https://github.com/nRo/DataFrame.git
$ git clone https://github.com/nRo/dataframe.git

2) Change to the created folder and run `mvn verify` (compile, tests, coverage gate and SpotBugs).
Use `mvn install` to install the library into your local repository.
Expand Down Expand Up @@ -118,7 +118,7 @@ All examples are executed by `ReadmeExamplesTest` using the files in `src/test/r
Select all users called Meier or Schmitt from Germany, group by age and add column that contains the number of users with the respective age.
Then sort by age and print
```java
URL csvUrl = new URL("https://raw.githubusercontent.com/nRo/DataFrame/master/src/test/resources/users.csv");
URL csvUrl = new URL("https://raw.githubusercontent.com/nRo/dataframe/master/src/test/resources/users.csv");

DataFrame users = DataFrame.load(csvUrl, FileFormat.CSV);

Expand All @@ -138,7 +138,7 @@ users.select("(name == 'Schmitt' || name == 'Meier') && country == 'Germany'")
Load a csv file, set a unique column as primary key and add an index for two other columns.
Select rows using the previously created index, change the values in their NAME column and join them with the original DataFrame.
```java
URL csvUrl = new URL("https://raw.githubusercontent.com/nRo/DataFrame/master/src/test/resources/data_index.csv");
URL csvUrl = new URL("https://raw.githubusercontent.com/nRo/dataframe/master/src/test/resources/data_index.csv");

DataFrame dataFrame = DataFrame.load(csvUrl, FileFormat.CSV);

Expand Down Expand Up @@ -356,21 +356,24 @@ DataFrame foundUsers = users.select(

```
Create and compile predicates from strings \
The queries are parsed by the [query-compiler](https://github.com/nRo/query-compiler) library. \
Available value comparison operations: \
```==, !=, <, <=, >, >=, ~= (regex)``` \
```==, !=, <, <=, >, >=, ~= (regex), *= (contains), LIKE, in (..), !in (..)``` \
Available predicate operations: \
```&&, ||, NOR, XOR, !(predicate) (negates the predicate) ```
```&&, ||, NOR, XOR, !(predicate) (negates the predicate) ``` \
Operator precedence: ```AND``` binds stronger than ```XOR```, which binds stronger than ```OR``` / ```NOR```. Use brackets to group terms.

```java
//find all users that are younger than 18 or older users with first_name == "Max"
DataFrame foundUsers = users.select("(age > 18 && first_name == 'Max') OR (age < 18)");

//Boolean column filter
//Boolean columns must be compared explicitly, a single word is not a valid query
//find all users that are older than 18 or the selected column is true
DataFrame foundUsers = users.select("(age > 18) OR selected");
DataFrame foundUsers = users.select("(age > 18) OR selected == true");

//find all users the selected column is false
DataFrame notSelected = users.select("!selected");
DataFrame notSelected = users.select("selected == false");

//compare tow columns
//returns all rows where col1 equals col2
Expand Down
32 changes: 8 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@

<groupId>dev.gruen</groupId>
<artifactId>dataframe</artifactId>
<version>0.8.0</version>
<version>0.8.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<antlr4.version>4.13.2</antlr4.version>
<slf4j.version>2.0.17</slf4j.version>
<junit.version>5.14.4</junit.version>
<spotbugs.failOnError>true</spotbugs.failOnError>
<jacoco.min.instruction>0.74</jacoco.min.instruction>
<jacoco.min.branch>0.70</jacoco.min.branch>
</properties>
<name>DataFrame</name>
<name>dataframe</name>
<description>DataFrame Library for Java</description>
<url>https://github.com/nRo/DataFrame</url>
<url>https://github.com/nRo/dataframe</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>https://github.com/nRo/DataFrame</url>
<connection>scm:git:https://github.com/nRo/DataFrame.git</connection>
<url>https://github.com/nRo/dataframe</url>
<connection>scm:git:https://github.com/nRo/dataframe.git</connection>
<tag>HEAD</tag>
</scm>
<developers>
Expand All @@ -41,9 +40,9 @@

<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
<groupId>dev.gruen</groupId>
<artifactId>query-compiler</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -134,21 +133,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.version}</version>
<configuration>
<visitor>true</visitor>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
Expand Down
4 changes: 0 additions & 4 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- generated ANTLR parser -->
<Match>
<Package name="dev.gruen.dataframe.generated"/>
</Match>

<!-- Accepted by design: a DataFrame wraps and exposes mutable columns and rows without defensive copies. -->
<Match>
Expand Down
102 changes: 0 additions & 102 deletions src/main/antlr4/dev/gruen/dataframe/generated/Predicate.g4

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import dev.gruen.dataframe.DataFrameRuntimeException;
import dev.gruen.dataframe.common.Row;
import dev.gruen.dataframe.filter.compile.PredicateCompiler;
import dev.gruen.query.Query;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -37,7 +38,7 @@
/**
* Created by Alex on 09.03.2016.
*/
public abstract class FilterPredicate {
public abstract class FilterPredicate implements Query {

public static final FilterPredicate EMPTY_FILTER = empty();

Expand Down

This file was deleted.

Loading
Loading