-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[test](show_data) test the correctness of data statistics in cloud mode #44947
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
|
||
|
||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
import org.apache.doris.regression.suite.Suite; | ||
import org.apache.doris.regression.Config; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.aliyun.oss.ClientException; | ||
import com.aliyun.oss.OSS; | ||
import com.aliyun.oss.OSSClientBuilder; | ||
import com.aliyun.oss.OSSException; | ||
import com.aliyun.oss.model.DeleteObjectsRequest; | ||
import com.aliyun.oss.model.DeleteObjectsResult; | ||
import com.aliyun.oss.model.ListObjectsRequest; | ||
import com.aliyun.oss.model.OSSObjectSummary; | ||
import com.aliyun.oss.model.ObjectListing; | ||
|
||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import groovy.util.logging.Slf4j | ||
|
||
Suite.metaClass.initOssClient = { String accessKeyId, String accessKeySecret, String endpoint -> | ||
return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret) | ||
} | ||
|
||
Suite.metaClass.listOssObjectWithPrefix = { OSS client, String bucketName, String prefix="" -> | ||
try { | ||
ObjectListing objectListing = null; | ||
String nextMarker = null; | ||
final int maxKeys = 500; | ||
List<OSSObjectSummary> sums = null; | ||
|
||
if (!client.doesBucketExist(bucketName)) { | ||
logger.info("no bucket named ${bucketName} in ${endpoint}") | ||
return | ||
} | ||
|
||
// Gets all object with specified marker by paging. Each page will have up to 100 entries. | ||
logger.info("List all objects with prefix:"); | ||
nextMarker = null; | ||
do { | ||
objectListing = client.listObjects(new ListObjectsRequest(bucketName). | ||
withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys)); | ||
|
||
sums = objectListing.getObjectSummaries(); | ||
for (OSSObjectSummary s : sums) { | ||
logger.info("\t" + s.getKey()); | ||
} | ||
|
||
nextMarker = objectListing.getNextMarker(); | ||
|
||
} while (objectListing.isTruncated()); | ||
} catch (OSSException oe) { | ||
logger.error("Caught an OSSException, which means your request made it to OSS, " | ||
+ "but was rejected with an error response for some reason."); | ||
logger.error("Error Message: " + oe.getErrorMessage()); | ||
logger.error("Error Code: " + oe.getErrorCode()); | ||
logger.error("Request ID: " + oe.getRequestId()); | ||
logger.error("Host ID: " + oe.getHostId()); | ||
} catch (ClientException ce) { | ||
logger.error("Caught an ClientException, which means the client encountered " | ||
+ "a serious internal problem while trying to communicate with OSS, " | ||
+ "such as not being able to access the network."); | ||
logger.error("Error Message: " + ce.getMessage()); | ||
} finally { | ||
/* | ||
* Do not forget to shut down the client finally to release all allocated resources. | ||
*/ | ||
//client.shutdown(); | ||
logger.info("Done!") | ||
} | ||
|
||
} | ||
|
||
// 获取某个存储空间下指定目录(文件夹)下的文件大小。 | ||
Suite.metaClass.calculateFolderLength = { OSS client, String bucketName, String folder -> | ||
long size = 0L; | ||
ObjectListing objectListing = null; | ||
do { | ||
// MaxKey默认值为100,最大值为1000。 | ||
ListObjectsRequest request = new ListObjectsRequest(bucketName).withPrefix(folder).withMaxKeys(1000); | ||
if (objectListing != null) { | ||
request.setMarker(objectListing.getNextMarker()); | ||
} | ||
objectListing = client.listObjects(request); | ||
List<OSSObjectSummary> sums = objectListing.getObjectSummaries(); | ||
for (OSSObjectSummary s : sums) { | ||
size += s.getSize(); | ||
} | ||
} while (objectListing.isTruncated()); | ||
return size; | ||
} | ||
|
||
Suite.metaClass.shutDownOssClient = { OSS client -> | ||
client.shutdown(); | ||
} | ||
|
||
|
||
|
||
Suite.metaClass.getOssAllDirSizeWithPrefix = { OSS client, String bucketName, String prefix="" -> | ||
try { | ||
if (!client.doesBucketExist(bucketName)) { | ||
logger.info("no bucket named ${bucketName} in ${endpoint}") | ||
return | ||
} | ||
|
||
// Gets all object with specified marker by paging. Each page will have up to 100 entries. | ||
logger.info("List all objects with prefix:"); | ||
ObjectListing objectListing = null; | ||
do { | ||
// 默认情况下,每次列举100个文件或目录。 | ||
ListObjectsRequest request = new ListObjectsRequest(bucketName).withDelimiter("/").withPrefix(prefix); | ||
if (objectListing != null) { | ||
request.setMarker(objectListing.getNextMarker()); | ||
} | ||
objectListing = client.listObjects(request); | ||
List<String> folders = objectListing.getCommonPrefixes(); | ||
for (String folder : folders) { | ||
logger.info(folder + " : " + (calculateFolderLength(client, bucketName, folder) / (1024 * 1024 * 1024)) + "GB"); | ||
} | ||
List<OSSObjectSummary> sums = objectListing.getObjectSummaries(); | ||
for (OSSObjectSummary s : sums) { | ||
logger.info(s.getKey() + " : " + (s.getSize() / (1024 * 1024 * 1024)) + "GB"); | ||
} | ||
} while (objectListing.isTruncated()); | ||
|
||
} catch (OSSException oe) { | ||
logger.error("Caught an OSSException, which means your request made it to OSS, " | ||
+ "but was rejected with an error response for some reason."); | ||
logger.error("Error Message: " + oe.getErrorMessage()); | ||
logger.error("Error Code: " + oe.getErrorCode()); | ||
logger.error("Request ID: " + oe.getRequestId()); | ||
logger.error("Host ID: " + oe.getHostId()); | ||
} catch (ClientException ce) { | ||
logger.error("Caught an ClientException, which means the client encountered " | ||
+ "a serious internal problem while trying to communicate with OSS, " | ||
+ "such as not being able to access the network."); | ||
logger.error("Error Message: " + ce.getMessage()); | ||
} finally { | ||
/* | ||
* Do not forget to shut down the client finally to release all allocated resources. | ||
*/ | ||
//client.shutdown(); | ||
logger.info("Done!") | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DELETE from ${table} where L_ORDERKEY >= 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE TABLE IF NOT EXISTS lineitem_mow ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lineitem_dup ? |
||
L_ORDERKEY INTEGER NOT NULL, | ||
L_PARTKEY INTEGER NOT NULL, | ||
L_SUPPKEY INTEGER NOT NULL, | ||
L_LINENUMBER INTEGER NOT NULL, | ||
L_QUANTITY DECIMAL(15,2) NOT NULL, | ||
L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL, | ||
L_DISCOUNT DECIMAL(15,2) NOT NULL, | ||
L_TAX DECIMAL(15,2) NOT NULL, | ||
L_RETURNFLAG CHAR(1) NOT NULL, | ||
L_LINESTATUS CHAR(1) NOT NULL, | ||
L_SHIPDATE DATE NOT NULL, | ||
L_COMMITDATE DATE NOT NULL, | ||
L_RECEIPTDATE DATE NOT NULL, | ||
L_SHIPINSTRUCT CHAR(25) NOT NULL, | ||
L_SHIPMODE CHAR(10) NOT NULL, | ||
L_COMMENT VARCHAR(44) NOT NULL | ||
) | ||
DUPLICATE KEY(L_ORDERKEY, L_PARTKEY, L_SUPPKEY, L_LINENUMBER) | ||
DISTRIBUTED BY HASH(L_ORDERKEY) BUCKETS 3 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE TABLE IF NOT EXISTS lineitem_mow ( | ||
L_ORDERKEY INTEGER NOT NULL, | ||
L_PARTKEY INTEGER NOT NULL, | ||
L_SUPPKEY INTEGER NOT NULL, | ||
L_LINENUMBER INTEGER NOT NULL, | ||
L_QUANTITY DECIMAL(15,2) NOT NULL, | ||
L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL, | ||
L_DISCOUNT DECIMAL(15,2) NOT NULL, | ||
L_TAX DECIMAL(15,2) NOT NULL, | ||
L_RETURNFLAG CHAR(1) NOT NULL, | ||
L_LINESTATUS CHAR(1) NOT NULL, | ||
L_SHIPDATE DATE NOT NULL, | ||
L_COMMITDATE DATE NOT NULL, | ||
L_RECEIPTDATE DATE NOT NULL, | ||
L_SHIPINSTRUCT CHAR(25) NOT NULL, | ||
L_SHIPMODE CHAR(10) NOT NULL, | ||
L_COMMENT VARCHAR(44) NOT NULL | ||
) | ||
UNIQUE KEY(L_ORDERKEY, L_PARTKEY, L_SUPPKEY, L_LINENUMBER) | ||
DISTRIBUTED BY HASH(L_ORDERKEY) BUCKETS 3 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
) | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
English