Skip to content

Commit

Permalink
ODBC: fetch data in batches
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgara authored and andrewseidl committed Jul 6, 2021
1 parent d3efae8 commit f4f962e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Catalog/ForeignTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct ForeignTable : public TableDescriptor, public OptionsContainer {
static constexpr const char* REFRESH_START_DATE_TIME_KEY = "REFRESH_START_DATE_TIME";
static constexpr const char* REFRESH_INTERVAL_KEY = "REFRESH_INTERVAL";
static constexpr const char* REFRESH_UPDATE_TYPE_KEY = "REFRESH_UPDATE_TYPE";
static constexpr const char* BUFFER_SIZE_KEY = "BUFFER_SIZE";
// Option values
static constexpr const char* ALL_REFRESH_UPDATE_TYPE = "ALL";
static constexpr const char* APPEND_REFRESH_UPDATE_TYPE = "APPEND";
Expand All @@ -69,7 +70,8 @@ struct ForeignTable : public TableDescriptor, public OptionsContainer {
inline static const std::set<const char*> alterable_options{REFRESH_TIMING_TYPE_KEY,
REFRESH_START_DATE_TIME_KEY,
REFRESH_INTERVAL_KEY,
REFRESH_UPDATE_TYPE_KEY};
REFRESH_UPDATE_TYPE_KEY,
BUFFER_SIZE_KEY};

/**
@brief Verifies the values for mapped options are valid.
Expand Down
30 changes: 30 additions & 0 deletions Tests/CreateAndDropTableDdlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,36 @@ class CreateForeignTableTest : public CreateAndDropTableDdlTest {
dropTestUser();
CreateAndDropTableDdlTest::TearDown();
}

void assertOptionEquals(const foreign_storage::ForeignTable* table,
const std::string& key,
const std::string& value) {
if (const auto& opt_it = table->options.find(key); opt_it != table->options.end()) {
ASSERT_EQ(opt_it->second, value);
} else {
FAIL() << "Expected value for option " << key;
}
}

const foreign_storage::ForeignTable* getForeignTable(
const std::string& filename) const {
auto table = getCatalog().getMetadataForTable(filename, false);
CHECK(table);
auto foreign_table = dynamic_cast<const foreign_storage::ForeignTable*>(table);
return foreign_table;
}

std::unique_ptr<const foreign_storage::ForeignTable> getForeignTableFromStorage(
const std::string& filename) const {
return getCatalog().getForeignTableFromStorage(getForeignTable(filename)->tableId);
}

// Asserts option is as expected for in-memory table then again in catalog storage.
void assertOptionEquals(const std::string& key, const std::string& value) {
assertOptionEquals(getForeignTable("test_foreign_table"), key, value);
assertOptionEquals(
getForeignTableFromStorage("test_foreign_table").get(), key, value);
}
};

TEST_F(CreateForeignTableTest, NonExistentServer) {
Expand Down
13 changes: 13 additions & 0 deletions Tests/ForeignTableDmlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4690,6 +4690,10 @@ class AlterForeignTableTest : public ScheduledRefreshTest {
}
query += ");";
sql(query);
populateForeignTable();
}

void populateForeignTable() {
cat_ = &getCatalog();
auto table = getCatalog().getMetadataForTable("test_foreign_table", false);
CHECK(table);
Expand Down Expand Up @@ -4873,6 +4877,15 @@ TEST_F(AlterForeignTableTest, RefreshStartDateTimeScheduledInPastError) {
assertOptionNotEquals("REFRESH_START_DATE_TIME", start_time);
}

TEST_F(AlterForeignTableTest, CsvBufferSizeOption) {
sql("CREATE FOREIGN TABLE test_foreign_table (i INTEGER) SERVER omnisci_local_csv WITH "
"(file_path='" +
getDataFilesPath() + "/1.csv');");
populateForeignTable();
sql("ALTER FOREIGN TABLE test_foreign_table SET (BUFFER_SIZE = '4');");
assertOptionEquals("BUFFER_SIZE", "4");
}

// TODO(Misiu): Implement these skeleton tests for full alter foreign table support.
TEST_F(AlterForeignTableTest, FilePath) {
createScheduledTable("manual");
Expand Down

0 comments on commit f4f962e

Please sign in to comment.