zeroshade commented on code in PR #59: URL: https://github.com/apache/iceberg-go/pull/59#discussion_r1503477206
########## catalog/catalog.go: ########## @@ -185,3 +197,33 @@ func TableNameFromIdent(ident table.Identifier) string { func NamespaceFromIdent(ident table.Identifier) table.Identifier { return ident[:len(ident)-1] } + +func getMetadataPath(locationPath string, newVersion int) (string, error) { + if newVersion < 0 { + return "", fmt.Errorf("invalid table version: %d must be a non-negative integer", newVersion) + } + + metaDataPath, err := url.JoinPath(strings.TrimLeft(locationPath, "/"), "metadata", fmt.Sprintf("%05d-%s.metadata.json", newVersion, uuid.New().String())) + if err != nil { + return "", fmt.Errorf("failed to build metadata path: %w", err) + } + + return metaDataPath, nil +} + +func getLocationForTable(location, defaultLocation, database, tableName string) (*url.URL, error) { + if location != "" { + return url.Parse(location) + } + + if defaultLocation == "" { + return nil, fmt.Errorf("no default path is set, please specify a location when creating a table") + } + + u, err := url.Parse(defaultLocation) + if err != nil { + return nil, fmt.Errorf("failed to parse location URL: %w", err) + } + + return u.JoinPath(fmt.Sprintf("%s.db", database), tableName), nil +} Review Comment: is the `*.db` syntax path specific to glue? I don't think it's used in the REST catalog at all. Should this go into `glue.go` instead of here? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org