You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The Go driver becomes "undefined: parser", and the application cannot be built. #1455
I think the reason behind this might be broken antlr dependencies, which are ridden with issues such as invalid function signatures and seem pretty low maintenance, so I'll try discussing ditching these with the project maintainers. I've tried using pgx as an alternative but it causes a memory leak while scanning 😞. @maehara-n, did you figure out any temporary solution?
@jrgemignani Prepare the JAVA environment, follow the steps to create the files, and place the files to eliminate the errors.
However, this cannot be called automated generation.
What troubles me is that I have to manually generate them.
@maehara-n The JAVA environment is up to the user to provide as is the database connection information. The other stuff, yeah, if it is stated to be automatic or automated, it isn't. The individual who wrote the scripts didn't write them very well. We will need to fix them. But, this is an open source project and it can be hard to manage all of the community provided code.
As for having to manually generate files, that shouldn't be an issue for you, provided the documentation either states how to do it or there are scripts to do it automatically.
@jrgemignani The explanation you provided seems to be for setting up the development environment of Apache AGE.
The issue I am facing is the build failure in the system that uses Apache AGE.
There is no JAVA environment.
@jrgemignani You suggested that building is possible if the generated file is placed, but where exactly should it be placed? Can you please provide more specific information?
The following steps can reproduce the error when creating the application:
ANTLR 4.11.1 or higher to be installed and included in the CLASSPATH
Golang 1.18 or higher to be installed.
As I mentioned, the README.md and associated installer scripts aren't very good. I have updated the README.md and the install.sh script in PR #1527 to verify that the above conditions are met. However, I have removed the installation of Java, ANTLR, and Golang from install.sh script as this should be done by the system administrator i.e. it is not our responsibility. Currently, I am waiting for that PR to be merged.
Once the above criteria are met, the parser and lexer can be built in the driver/golang/age directory via the install.sh script. The current generate.sh script in that directory generally works, but also needs to be updated or removed.
I need to clarify that the install.sh script will verify the minimum prerequisites listed above and then it will build and install the Go driver. The generate.sh script in the parser directory is for the Github CI scripts, so just ignore it.
@jrgemignani I have reviewed the update, but it will not solve the problem.
The solution you provided assumes working within the age project, which includes:
age
drivers
golang
age
parser
samples
myapp
age_wrapper_sample.go
main.go
sql_api_sample.go
However, my "myapp" project is structured as follows:
There is no "install.sh" in myapp project and Java is not installed either.
The reason for the error with the go driver is that there is no file in the age repository.
package main
import (
"fmt"
_ "github.com/lib/pq"
)
// var dsn string = "host={host} port={port} dbname={dbname} user={username} password={password} sslmode=disable"
var dsn string = "host=127.0.0.1 port=5432 dbname=postgres user=postgres password=agens sslmode=disable"
// var graphName string = "{graph_path}"
var graphName string = "testGraph"
func main() {
// Do cypher query to AGE with database/sql Tx API transaction control
fmt.Println("# Do cypher query with SQL API")
doWithSqlAPI(dsn, graphName)
// Do cypher query to AGE with Age API
fmt.Println("# Do cypher query with Age API")
doWithAgeWrapper(dsn, graphName)
}
sql_api_sample.go
package main
import (
"database/sql"
"fmt"
"github.com/apache/age/drivers/golang/age"
)
// Do cypher query to AGE with database/sql Tx API transaction control
func doWithSqlAPI(dsn string, graphName string) {
// Connect to PostgreSQL
db, err := sql.Open("postgres", dsn)
if err != nil {
panic(err)
}
// Confirm graph_path created
_, err = age.GetReady(db, graphName)
if err != nil {
panic(err)
}
// Tx begin for execute create vertex
tx, err := db.Begin()
if err != nil {
panic(err)
}
// Create vertices with Cypher
_, err = age.ExecCypher(tx, graphName, 0, "CREATE (n:Person {name: '%s', weight:%f})", "Joe", 67.3)
if err != nil {
panic(err)
}
_, err = age.ExecCypher(tx, graphName, 0, "CREATE (n:Person {name: '%s', weight:77.3, roles:['Dev','marketing']})", "Jack")
if err != nil {
panic(err)
}
_, err = age.ExecCypher(tx, graphName, 0, "CREATE (n:Person {name: '%s', weight:%d})", "Andy", 59)
if err != nil {
panic(err)
}
// Commit Tx
tx.Commit()
// Tx begin for queries
tx, err = db.Begin()
if err != nil {
panic(err)
}
// Query cypher
cypherCursor, err := age.ExecCypher(tx, graphName, 1, "MATCH (n:Person) RETURN n")
if err != nil {
panic(err)
}
// Unmarshal result data to Vertex row by row
for cypherCursor.Next() {
row, err := cypherCursor.GetRow()
if err != nil {
panic(err)
}
vertex := row[0].(*age.Vertex)
fmt.Println(vertex.Id(), vertex.Label(), vertex.Props())
}
// Create Paths (Edges)
_, err = age.ExecCypher(tx, graphName, 0, "MATCH (a:Person), (b:Person) WHERE a.name='%s' AND b.name='%s' CREATE (a)-[r:workWith {weight: %d}]->(b)", "Jack", "Joe", 3)
if err != nil {
panic(err)
}
_, err = age.ExecCypher(tx, graphName, 0, "MATCH (a:Person {name: '%s'}), (b:Person {name: '%s'}) CREATE (a)-[r:workWith {weight: %d}]->(b)", "Joe", "Andy", 7)
if err != nil {
panic(err)
}
tx.Commit()
tx, err = db.Begin()
if err != nil {
panic(err)
}
// Query Paths with Cypher
cypherCursor, err = age.ExecCypher(tx, graphName, 1, "MATCH p=()-[:workWith]-() RETURN p")
if err != nil {
panic(err)
}
for cypherCursor.Next() {
row, err := cypherCursor.GetRow()
if err != nil {
panic(err)
}
path := row[0].(*age.Path)
vertexStart := path.GetAsVertex(0)
edge := path.GetAsEdge(1)
vertexEnd := path.GetAsVertex(2)
fmt.Println(vertexStart, edge, vertexEnd)
}
// Query with return many columns
cursor, err := age.ExecCypher(tx, graphName, 3, "MATCH (a:Person)-[l:workWith]-(b:Person) RETURN a, l, b")
if err != nil {
panic(err)
}
count := 0
for cursor.Next() {
row, err := cursor.GetRow()
if err != nil {
panic(err)
}
count++
v1 := row[0].(*age.Vertex)
edge := row[1].(*age.Edge)
v2 := row[2].(*age.Vertex)
fmt.Println("ROW ", count, ">>", "\n\t", v1, "\n\t", edge, "\n\t", v2)
}
// Delete Vertices
_, err = age.ExecCypher(tx, graphName, 0, "MATCH (n:Person) DETACH DELETE n RETURN *")
if err != nil {
panic(err)
}
tx.Commit()
}
Activity
mjholub commentedon Jan 11, 2024
I think the reason behind this might be broken antlr dependencies, which are ridden with issues such as invalid function signatures and seem pretty low maintenance, so I'll try discussing ditching these with the project maintainers. I've tried using pgx as an alternative but it causes a memory leak while scanning 😞. @maehara-n, did you figure out any temporary solution?
jrgemignani commentedon Jan 18, 2024
@maehara-n You need to build those files by executing generate.sh -
jrgemignani commentedon Jan 18, 2024
Both the README and install.sh files aren't very good. If you look at the install file, you will basically need to -
CLASSPATH.install.shfile.After that you should be good to go.
maehara-n commentedon Jan 22, 2024
@jrgemignani Prepare the JAVA environment, follow the steps to create the files, and place the files to eliminate the errors.
However, this cannot be called automated generation.
What troubles me is that I have to manually generate them.
jrgemignani commentedon Jan 22, 2024
@maehara-n The JAVA environment is up to the user to provide as is the database connection information. The other stuff, yeah, if it is stated to be automatic or automated, it isn't. The individual who wrote the scripts didn't write them very well. We will need to fix them. But, this is an open source project and it can be hard to manage all of the community provided code.
As for having to manually generate files, that shouldn't be an issue for you, provided the documentation either states how to do it or there are scripts to do it automatically.
maehara-n commentedon Jan 25, 2024
@jrgemignani The explanation you provided seems to be for setting up the development environment of Apache AGE.
The issue I am facing is the build failure in the system that uses Apache AGE.
There is no JAVA environment.
maehara-n commentedon Jan 25, 2024
@mjholub We specify the following older version in go.mod.
github.com/apache/age/drivers/golang v0.0.0-20230125234102-2a233e3e2da9
jrgemignani commentedon Jan 26, 2024
@maehara-n What I gave are directions for building the Go driver for AGE. Building it requires JAVA and ANTLR to be installed.
maehara-n commentedon Jan 31, 2024
@jrgemignani You suggested that building is possible if the generated file is placed, but where exactly should it be placed? Can you please provide more specific information?
The following steps can reproduce the error when creating the application:
Create a directory named "myapp"
Execute the following command:
go mod init myappPlace the files under the directory "https://github.com/apache/age/tree/master/drivers/golang/samples" into the "myapp" directory.
Run the following command:
go mod tidy-> The following go.mod file is created:
Run the following command:
go build -o /out-> An error will be outputted.
jrgemignani commentedon Jan 31, 2024
@maehara-n Building requires -
As I mentioned, the
README.mdand associated installer scripts aren't very good. I have updated theREADME.mdand theinstall.shscript in PR #1527 to verify that the above conditions are met. However, I have removed the installation of Java, ANTLR, and Golang frominstall.shscript as this should be done by the system administrator i.e. it is not our responsibility. Currently, I am waiting for that PR to be merged.Once the above criteria are met, the parser and lexer can be built in the
driver/golang/agedirectory via theinstall.shscript. The currentgenerate.shscript in that directory generally works, but also needs to be updated or removed.jrgemignani commentedon Feb 1, 2024
Update -
I need to clarify that the
install.shscript will verify the minimum prerequisites listed above and then it will build and install the Go driver. Thegenerate.shscript in theparserdirectory is for the Github CI scripts, so just ignore it.All of the changes are now in the master branch.
maehara-n commentedon Feb 2, 2024
@jrgemignani I have reviewed the update, but it will not solve the problem.
The solution you provided assumes working within the age project, which includes:
However, my "myapp" project is structured as follows:
The content of go.mod is:
There is no "install.sh" in myapp project and Java is not installed either.
The reason for the error with the go driver is that there is no file in the age repository.
jrgemignani commentedon Feb 2, 2024
Which file(s) are you referring to? The ones in parser?
maehara-n commentedon Feb 5, 2024
@jrgemignani The code for "myapp" is just importing and using "github.com/apache/age/drivers/golang/age".
The driver is referencing the parser.
"myapp" project is structured as follows:
main.go
sql_api_sample.go
age_wrapper_sample.go
If I describe go.mod as follows, the build will fail.
If I describe go.mod as follows, the build will succeed.
17 remaining items
maehara-n commentedon Feb 16, 2024
@jrgemignani Thank you for your support.
sanket-uptycs commentedon Feb 16, 2024
@jrgemignani Thanks man !
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (apache#1582)
Update Go installation and add in parser files (#1582) (#1620)
Update Go installation and add in parser files (#1582) (#1621)
Update Go installation and add in parser files (#1582) (#1622)
Update Go installation and add in parser files (#1582) (#1623)
Update Go installation and add in parser files (#1582) (#1624)
Update Go installation and add in parser files (#1582) (#1625)