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

In-memory Connector #1262

Merged
merged 5 commits into from
Nov 10, 2023
Merged

In-memory Connector #1262

merged 5 commits into from
Nov 10, 2023

Conversation

yliuuuu
Copy link
Contributor

@yliuuuu yliuuuu commented Nov 2, 2023

Relevant Issues

  • [Closes/Related To] Issue #XXX

Description

  • Adds in memory connector for testing purpose.
  • Fixes the CI builds.

Notes on CI builds:

  1. Github actions used packaged code (JAR) for build.
    • We can not turn folder/files in Jar to a Java File object easily, especially with the current set up in which the local plugin takes a path and we retrieve the path and turn it to File object later.
    • Solution:
      • During build process, we list out the path to each individual test resource, and store the path into a single file.
      • We retrieve the content of resource using path, and load the content to a in-memory connector.
  2. Github checkout action is not running against the code in the RP. Instead, it runs against some merged version that is based on top of the target branch.
    Fix : https://github.com/actions/checkout/blob/v3.0.2/README.md#user-content-checkout-pull-request-head-commit-instead-of-merge-commit

Commits:

  • a4719e4 : Implemented and tested the in-memory connector
  • 130e2ab : Switch the schema inferencer to use in-memory plugin. This includes the logic to generate a resource_path.txt file during build process, and use the file to populate the in-memory connector. Also, currently we have a couple test cases that are failing due to the ANY function resolution in plan. I added a IgnoredTestCase to workaround this issue.
  • 681c593: This commits changes the loading logic of test case provider.
  • a358d71 : This commits change the checkout action to run on pull request head commit.

Other Information

  • Updated Unreleased Section in CHANGELOG: [YES/NO]

    • No.
  • Any backward-incompatible changes? [YES/NO]

    • No.
  • Any new external dependencies? [YES/NO]

    • No.
  • Do your changes comply with the Contributing Guidelines
    and Code Style Guidelines? [YES/NO]
    Yes.

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

github-actions bot commented Nov 2, 2023

Conformance comparison report

Base (3f3bb7b) 2c3d2a4 +/-
% Passing 92.33% 92.33% 0.00%
✅ Passing 5372 5372 0
❌ Failing 446 446 0
🔶 Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5372

Number failing in both: 446

Number passing in Base (3f3bb7b) but now fail: 0

Number failing in Base (3f3bb7b) but now pass: 0

@yliuuuu
Copy link
Contributor Author

yliuuuu commented Nov 6, 2023

Pause this work.

The issue is related to local plugin.

The local plugin attempts retrieve catalog/schema via xxx.class.getResource(...). It treats directory as catalog.

In local build the files system approach works fine as we can directly access the file via URI.

For some reasons, in GitHub work flow, the build runs jar instead of a local file system. We could not convert a folder in Jar to Java File Object.

TODO:

  1. Figure out why GitHub work flow runs the jar instead of extracting from file system.
  2. If necessary, we may need a in-memory connector.

@yliuuuu yliuuuu changed the title Planner CI Fix In-memory Connector Nov 9, 2023
@yliuuuu yliuuuu marked this pull request as ready for review November 9, 2023 22:37
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (partiql-planner@3f3bb7b). Click here to learn what that means.

Additional details and impacted files
@@                Coverage Diff                 @@
##             partiql-planner    #1262   +/-   ##
==================================================
  Coverage                   ?   72.01%           
  Complexity                 ?     2058           
==================================================
  Files                      ?      221           
  Lines                      ?    15872           
  Branches                   ?     2853           
==================================================
  Hits                       ?    11431           
  Misses                     ?     3634           
  Partials                   ?      807           
Flag Coverage Δ
CLI 13.36% <0.00%> (?)
EXAMPLES 80.28% <0.00%> (?)
LANG 80.47% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +142 to +167
val catalogProvider = MemoryCatalog.Provider().also {
val map = mutableMapOf<String, MutableList<Pair<String, StaticType>>>()
inputStream.reader().readLines().forEach { path ->
if (path.startsWith("catalogs/default")) {
val schema = this::class.java.getResourceAsStream("/$path")!!
val ion = loadSingleElement(schema.reader().readText())
val staticType = ion.toStaticType()
val steps = path.split('/').drop(2) // drop the catalogs/default
val catalogName = steps.first()
val subPath = steps
.drop(1)
.joinToString(".") { it.lowercase() }
.let {
it.substring(0, it.length - 4)
}
if (map.containsKey(catalogName)) {
map[catalogName]!!.add(subPath to staticType)
} else {
map[catalogName] = mutableListOf(subPath to staticType)
}
}
}
map.forEach { (k: String, v: MutableList<Pair<String, StaticType>>) ->
it[k] = MemoryCatalog.of(*v.toTypedArray())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, rather than porting the catalogs from the .ion files you create the mem catalog from them. This works, but would be nice to clean up the resources in a later PR. Again, these are testing concerns so nothing pressing

Comment on lines +35 to +38
// TODO: This code is ported from plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalSchema.kt
// In my opinion, the in-memory connector should be independent of schema file format,
// hence making it inappropriate to leave the code in plugins/partiql-memory
// We need to figure out where to put the code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving the catalogs from resources to in-memory is a better long term solution and don't need to duplicate this.

@yliuuuu yliuuuu merged commit 9e1bebe into partiql-planner Nov 10, 2023
10 checks passed
@yliuuuu yliuuuu deleted the planner-ci branch November 10, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants