-
Notifications
You must be signed in to change notification settings - Fork 279
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
Work in Progress Stage URL #17973
Work in Progress Stage URL #17973
Conversation
…QL by InternalSqlExecutor
…al' but actual 'Etc/UTC'
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨
|
@@ -1442,9 +1442,9 @@ const ( | |||
|
|||
checkStageFormat = `select stage_id, stage_name from mo_catalog.mo_stages where stage_name = "%s" order by stage_id;` | |||
|
|||
checkStageStatusFormat = `select stage_id, stage_name from mo_catalog.mo_stages where stage_status = "%s" order by stage_id;` | |||
//checkStageStatusFormat = `select stage_id, stage_name from mo_catalog.mo_stages where stage_status = "%s" order by stage_id;` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove it, if it wil not be used anymore.
@@ -1522,20 +1522,25 @@ func getSqlForCheckStage(ctx context.Context, stage string) (string, error) { | |||
return fmt.Sprintf(checkStageFormat, stage), nil | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
if err != nil { | ||
return err | ||
} | ||
|
||
// detect filepath contain stage or not | ||
filePath = ep.FilePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is changed in this PR. There is no need to query the stage record and check it. Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable/disable in stage_status is not valid. The path expansion is done in pkg/sql/plan/function/stage_util.go now.
bh.sql2result["commit;"] = nil | ||
bh.sql2result["rollback;"] = nil | ||
|
||
err := doCheckFilePath(ctx, ses, cs.Ep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due the change of implementation of the doCheckFilePath. So the UT is removed in this PR. But doCheckFilePath needs a simpler UT instead of none.
filePath = getExportFilePath(ep.userConfig.FilePath, ep.FileCnt) | ||
} | ||
ep.File, err = OpenFile(filePath, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0o666) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fileservice unify the operation on the file.
@@ -557,16 +476,15 @@ func addEscapeToString(s []byte) []byte { | |||
return ret | |||
} | |||
|
|||
func exportDataToCSVFile(oq *ExportConfig) error { | |||
if !oq.OutTofile { | |||
return exportDataToCSVFile2(oq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this branch should be removed?
symbol := oq.Symbol | ||
closeby := oq.userConfig.Fields.EnclosedBy.Value | ||
flag := oq.ColumnFlag | ||
|
||
buffer := &bytes.Buffer{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes.Buffer allocate memory every time. the memory may explode
convey.So(writeToCSVFile(ep, output), convey.ShouldNotBeNil) | ||
|
||
ep.Rows = 1 | ||
stubs := gostub.StubFunc(&Flush, moerr.NewInternalError(context.TODO(), "Flush error")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Means, these variables has beend removed in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, Writer is removed. We only support AsyncWriter and AsyncReader. For LineSize, it is same as FileSize. variables should be removed.
exportParam.FileService = getGlobalPu().FileService | ||
exportParam.Ctx = ctx | ||
defer func() { | ||
exportParam.LineBuffer = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two buffers for resuing memory. Is it really necessary to remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LineBuffer should be a local variable inside a function. Not need to be a member variable.
LineStr is a also local variable.
err := updateTimeZone(ctx, ses, ses.GetSessionSysVars(), "time_zone", "system") | ||
assert.NoError(t, err) | ||
assert.Equal(t, ses.GetTimeZone().String(), "Local") | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this UT should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my machihe, the return value is UTC but not local. The result is not always True
User description
What type of PR is this?
Which issue(s) this PR fixes:
issue #
What this PR does / why we need it:
SQL failed to run and return error "context canceled".
operating system:
ubuntu24
go version:
go 1.22.4
To reproduce the case,
data file /tmp/data/a.csv
SQL command to reproduce,
Result
GDB
b stage_util.go:175
run LOAD DATA SQL and break in stage_util.go
set breakpoint in sql_executor.go
b sql_executor.go:246
b backend.go:581
GDB LOG HERE
There is a race.
PR Type
Bug fix, Enhancement, Tests
Description
Changes walkthrough 📝
12 files
export.go
Refactor export logic to use file service and buffer.
pkg/frontend/export.go
ExportConfig
to remove file handling and buffer writer.stage_util.go
Add utility functions for stage URL handling and file listing.
pkg/sql/plan/function/stage_util.go
wildcards.
authenticate.go
Update stage creation and credential handling logic.
pkg/frontend/authenticate.go
utils.go
Add and refactor parameter initialization for stage URLs.
pkg/sql/plan/utils.go
func_unary.go
Add StageList function for listing files in a stage.
pkg/sql/plan/function/func_unary.go
StageList
function to list files in a stage.list_builtIn.go
Add stage_list function to built-in functions.
pkg/sql/plan/function/list_builtIn.go
stage_list
function to the list of supported built-in functions.compile.go
Support stage URLs in external scan compilation.
pkg/sql/compile/compile.go
query_result.go
Refactor query result dumping to use new export logic.
pkg/frontend/query_result.go
function_id.go
Add STAGE_LIST function ID.
pkg/sql/plan/function/function_id.go
STAGE_LIST
function ID.status_stmt.go
Refactor status statement execution to use new export logic.
pkg/frontend/status_stmt.go
build_load.go
Support stage URLs in file existence check.
pkg/sql/plan/build_load.go
external.go
Support stage URLs in external stats initialization.
pkg/sql/plan/external.go
12 files
authenticate_test.go
Update test cases for stage URL and credentials format.
pkg/frontend/authenticate_test.go
export_test.go
Refactor export tests to use buffer and remove file handling.
pkg/frontend/export_test.go
session_test.go
Comment out test case for updating time zone to system.
pkg/frontend/session_test.go
nonsys_restore_system_table_to_nonsys_account.result
Update timestamps and snapshot results.
test/distributed/cases/snapshot/nonsys_restore_system_table_to_nonsys_account.result
load_data_parquet.result
Add test results for loading data from a stage.
test/distributed/cases/load_data/load_data_parquet.result
load_data_parquet.sql
Add test case for loading data from a stage.
test/distributed/cases/load_data/load_data_parquet.sql
cluster_level_snapshot_restore_system_table_to_nonsys.result
Update timestamps and stage credentials in snapshot tests
test/distributed/cases/snapshot/cluster_level_snapshot_restore_system_table_to_nonsys.result
sys_restore_system_table_to_nonsys_account.result
Update timestamps and stage credentials in sys restore tests
test/distributed/cases/snapshot/sys_restore_system_table_to_nonsys_account.result
sys_restore_system_table_to_newnonsys_account.result
Update timestamps and stage credentials in sys restore to new account
tests
test/distributed/cases/snapshot/sys_restore_system_table_to_newnonsys_account.result
stage.result
Add and update stage creation and data loading tests
test/distributed/cases/stage/stage.result
stage.sql
Refactor stage URLs and enhance test cases for stages
test/distributed/cases/stage/stage.sql
restore_cluster_table.result
Update test results with new timestamps and credentials format
test/distributed/cases/snapshot/cluster/restore_cluster_table.result