{"id":15069178,"url":"https://github.com/milenkovicm/adhesive","last_synced_at":"2025-04-10T16:51:49.866Z","repository":{"id":228077848,"uuid":"772944535","full_name":"milenkovicm/adhesive","owner":"milenkovicm","description":"Apache Datafusion JVM User Defined Functions (UDF), integration nobody asked for 😀","archived":false,"fork":false,"pushed_at":"2025-04-01T06:02:18.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T07:21:51.486Z","etag":null,"topics":["arrow","bytecode-compiler","compiler","datafusion","java","jni","jvm","rust","sql","udf","udf-libraries","userdefined-functions"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milenkovicm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-16T10:05:58.000Z","updated_at":"2025-04-01T06:02:17.000Z","dependencies_parsed_at":"2024-04-05T08:30:57.791Z","dependency_job_id":"a2e56b2a-f7b4-4205-8968-2eccd7a1f0bc","html_url":"https://github.com/milenkovicm/adhesive","commit_stats":null,"previous_names":["milenkovicm/adhesive"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milenkovicm%2Fadhesive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milenkovicm%2Fadhesive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milenkovicm%2Fadhesive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milenkovicm%2Fadhesive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milenkovicm","download_url":"https://codeload.github.com/milenkovicm/adhesive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248256077,"owners_count":21073458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrow","bytecode-compiler","compiler","datafusion","java","jni","jvm","rust","sql","udf","udf-libraries","userdefined-functions"],"created_at":"2024-09-25T01:40:53.567Z","updated_at":"2025-04-10T16:51:49.844Z","avatar_url":"https://github.com/milenkovicm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adhesive - Datafusion Integration Nobody Asked For\n\nVery opinionated datafusion user defined functions written in java.\n\nIt has been implemented to demonstrate DataFusion `FunctionFactory` functionality ([arrow-datafusion/pull#9333](https://github.com/apache/arrow-datafusion/pull/9333)).\n\n\u003e [!NOTE]\n\u003e It has not been envisaged as a actively maintained library.\n\u003e\nOther project utilizing `FunctionFactory`:\n\n- [Torchfusion, Opinionated Torch Inference on DataFusion](https://github.com/milenkovicm/torchfusion)\n- [LightGBM Inference on DataFusion](https://github.com/milenkovicm/lightfusion)\n\n## How To Use\n\nA java user defined function can be defined using `CREATE FUNCTION`:\n\n```sql\nCREATE FUNCTION f1(BIGINT, BIGINT)\nRETURNS BIGINT\nLANGUAGE JAVA\nAS '\npublic class NewClass extends com.github.milenkovicm.adhesive.Adhesive {\n    @Override\n    public Long compute(org.apache.arrow.vector.table.Row row) {\n        return row.getBigInt(0) * row.getBigInt(1); \n    }\n}\n'\n```\n\nwhich will be compiled. Or, referencing existing compiled class:\n\n```sql\nCREATE FUNCTION f2(BIGINT, BIGINT)\nRETURNS BIGINT\nLANGUAGE CLASS\nAS \"com.github.milenkovicm.adhesive.example.BasicExample\"\n```\n\nNote change of `LANGUAGE`. In both cases classes should extend `com.github.milenkovicm.adhesive.Adhesive` abstract class,\nwhich will do transition between rust and java.\n\n`com.github.milenkovicm.adhesive.example.BasicExample` is defined like:\n\n```java\npackage com.github.milenkovicm.adhesive.example;\n\nimport com.github.milenkovicm.adhesive.Adhesive;\nimport org.apache.arrow.vector.table.Row;\n\npublic class BasicExample extends Adhesive {\n  @Override\n  protected Long compute(Row row) {\n    return row.getBigInt(0) + row.getBigInt(1);\n  }\n}\n```\n\nDefined functions can be invoked in SQL:\n\n```sql\nSELECT f2(a,b) FROM t\n```\n\n## Setup\n\n```rust\n// JAR containing required libraries and additional classes \nconst JAR_PATH: \u0026str =\"adhesive-1.0-jar-with-dependencies.jar\";\nlet ctx = SessionContext::new()\n    .with_function_factory(Arc::new(JvmFunctionFactory::new_with_jar(JAR_PATH)?));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilenkovicm%2Fadhesive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilenkovicm%2Fadhesive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilenkovicm%2Fadhesive/lists"}