Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make antlr filter return empty result set when fails. #1490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ case class AntlrBasedFilter(clause: FilterClause) extends Filter with StrictLogg
filteredKeys
case Error(msg) =>
logger.error(s"Unexpected error occurred while filtering (skipping filters): \n$msg")
primaryKeys
EmptyTablePrimaryKeys
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package org.finos.vuu.core.filter

import org.antlr.v4.runtime.misc.ParseCancellationException
import org.finos.vuu.core.filter.FilterSpecParser.{parse => filterClause}
import org.finos.vuu.core.sort.FilterAndSortFixture.{row, _}
import org.finos.vuu.core.sort.FilterAndSortFixture._
import org.finos.vuu.core.table.RowWithData
import org.scalatest.featurespec.AnyFeatureSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.prop.TableDrivenPropertyChecks._

import scala.collection.immutable

class FilterGrammarTest extends AnyFeatureSpec with Matchers {
def assertParsable(filter: String): Unit = filterClause(filter) shouldBe a[FilterClause]
def assertNotParsable(filter: String): Unit = an [ParseCancellationException] should be thrownBy filterClause(filter)
Expand Down Expand Up @@ -277,10 +279,10 @@ class FilterGrammarTest extends AnyFeatureSpec with Matchers {
)
}

Scenario("filter on a non-existent column skips filtering and returns result unchanged") {
Scenario("filter on a non-existent column returns empty results") {
val table = setupTable2()
val clause = filterClause("ccyCross = \"$GBPUSD\" and nonExistent = 10")
getFilteredRows(table, clause).map(_.key).toSet shouldEqual table.primaryKeys.toSet
getFilteredRows(table, clause).map(_.key).toSet shouldEqual immutable.Set.empty
}
}
}
Loading