wolfeidau commented on code in PR #59: URL: https://github.com/apache/iceberg-go/pull/59#discussion_r1504975878
########## 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: @zeroshade I found this pattern in the python library, but I have seen it when I created a table using spark as well I think. I thought it was quite neat, and wanted to dig into where it came from but didn't get a chance. -- 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