-
Notifications
You must be signed in to change notification settings - Fork 186
ODBC: Fix for data loading failure in Power BI Desktop #627
Changes from 26 commits
427bd79
401a053
11856cd
e693269
4158974
586793f
9cb48a4
c234b88
0d0c050
50d4ccf
023fb67
0b857c0
06ae486
b2ff222
3f6ff5d
ad73d91
91d5cbe
ddc725b
b946351
2bd944c
ed0afb9
22dc963
82e9a72
5022f1f
f4c7068
a76c382
debe0c5
6add9da
a80eee8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,8 @@ const int delay_offset_3_1 = 0; | |
const int delay_offset_3_2 = 180; | ||
const SQLSMALLINT single_col_name_length = 6; | ||
const SQLSMALLINT single_col_data_type = SQL_WVARCHAR; | ||
const SQLULEN single_col_column_size = 25; | ||
const SQLULEN single_col_column_size_25 = 25; | ||
const SQLULEN single_col_column_size_15 = 15; | ||
const SQLSMALLINT single_col_decimal_digit = 0; | ||
const SQLSMALLINT single_col_nullable = 2; | ||
const std::wstring single_row = L"1"; | ||
|
@@ -936,7 +937,9 @@ TEST_F(TestSQLDescribeCol, SingleColumnMetadata) { | |
EXPECT_EQ(single_col, m_column_name); | ||
EXPECT_EQ(single_col_name_length, m_column_name_length); | ||
EXPECT_EQ(single_col_data_type, m_data_type); | ||
EXPECT_EQ(single_col_column_size, m_column_size); | ||
// Value changes according to pagination setup on server | ||
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. Why is this? 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. Not sure why. Created an issue #628 to investigate this further since I got one another value as 23 for server Will revert changes in this PR and handle this separately as it's not a blocker for fixing the data loading issue in Power BI. |
||
EXPECT_TRUE((single_col_column_size_25 == m_column_size) | ||
|| (single_col_column_size_15 == m_column_size)); | ||
EXPECT_EQ(single_col_decimal_digit, m_decimal_digits); | ||
EXPECT_EQ(single_col_nullable, m_nullable); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,22 @@ const std::unordered_map< int, std::vector< int > > sql_es_type_map = { | |
{ES_TYPE_KEYWORD, ES_TYPE_TEXT, ES_TYPE_NESTED, ES_TYPE_OBJECT}}, | ||
{SQL_TYPE_TIMESTAMP, {ES_TYPE_DATETIME}}}; | ||
|
||
const std::unordered_map< std::string, int > data_name_data_type_map = { | ||
{ES_TYPE_NAME_BOOLEAN, SQL_BIT}, | ||
{ES_TYPE_NAME_BYTE, SQL_TINYINT}, | ||
{ES_TYPE_NAME_SHORT, SQL_SMALLINT}, | ||
{ES_TYPE_NAME_INTEGER, SQL_INTEGER}, | ||
{ES_TYPE_NAME_LONG, SQL_BIGINT}, | ||
{ES_TYPE_NAME_HALF_FLOAT, SQL_REAL}, | ||
{ES_TYPE_NAME_FLOAT, SQL_REAL}, | ||
{ES_TYPE_NAME_DOUBLE, SQL_DOUBLE}, | ||
{ES_TYPE_NAME_SCALED_FLOAT, SQL_DOUBLE}, | ||
{ES_TYPE_NAME_KEYWORD, SQL_WVARCHAR}, | ||
{ES_TYPE_NAME_TEXT, SQL_WVARCHAR}, | ||
{ES_TYPE_NAME_DATE, ES_TYPE_TIMESTAMP}, | ||
{ES_TYPE_NAME_OBJECT, SQL_WVARCHAR}, | ||
{ES_TYPE_NAME_NESTED, SQL_WVARCHAR}}; | ||
|
||
// Boilerplate code for easy column bind handling | ||
class BindTemplate { | ||
public: | ||
|
@@ -476,8 +492,28 @@ void SetTableTuples(QResultClass *res, const TableResultSet res_type, | |
// information for its Data Preview window. | ||
std::string catalog(""); | ||
bind_tbl[TABLES_CATALOG_NAME]->UpdateData((void *)catalog.c_str(), 0); | ||
for (size_t i = 0; i < binds.size(); i++) | ||
binds[i]->AssignData(&tuple[i]); | ||
|
||
for (size_t i = 0; i < binds.size(); i++) { | ||
// Add tuples for SQLColumns | ||
if (binds.size() > COLUMNS_SQL_DATA_TYPE) { | ||
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. Should we just report the extra columns regardless? 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. The same method is used while adding tuples for SQLTables as well. SQLTables has only 5 columns whereas SQLColumns has 18. 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. Almost wondering if it would be worth it to split some of this logic up, now that we're handling special cases for SQLTables & SQLColumns 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. Created issue #630 to revisit the logic of assigning data for SQLTables & SQLColumns |
||
// Add data type for data loading issue in Power BI Desktop | ||
auto data_type = data_name_data_type_map | ||
.find(bind_tbl[COLUMNS_TYPE_NAME]->AsString())->second; | ||
if (i == COLUMNS_DATA_TYPE) { | ||
set_tuplefield_int2(&tuple[COLUMNS_DATA_TYPE], | ||
static_cast< short >(data_type)); | ||
} else if (i == COLUMNS_SQL_DATA_TYPE) { | ||
set_tuplefield_int2(&tuple[COLUMNS_SQL_DATA_TYPE], | ||
static_cast< short >(data_type)); | ||
} else { | ||
binds[i]->AssignData(&tuple[i]); | ||
} | ||
} | ||
// Add tuples for SQLTables | ||
else { | ||
binds[i]->AssignData(&tuple[i]); | ||
} | ||
} | ||
}; | ||
|
||
// General case | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#pragma clang diagnostic pop | ||
#endif // __APPLE__ | ||
#include "statement.h" | ||
#include "es_types.h" | ||
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. Already included on L22 (might need to expand GH code preview) 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. removed |
||
|
||
typedef std::vector< std::pair< std::string, OID > > schema_type; | ||
typedef rabbit::array json_arr; | ||
|
@@ -69,21 +70,21 @@ static const std::string JSON_KW_CURSOR = "cursor"; | |
|
||
// clang-format on | ||
const std::unordered_map< std::string, OID > type_to_oid_map = { | ||
{"boolean", ES_TYPE_BOOL}, | ||
{"byte", ES_TYPE_INT2}, | ||
{"short", ES_TYPE_INT2}, | ||
{"integer", ES_TYPE_INT4}, | ||
{"long", ES_TYPE_INT8}, | ||
{"half_float", ES_TYPE_FLOAT4}, | ||
{"float", ES_TYPE_FLOAT4}, | ||
{"double", ES_TYPE_FLOAT8}, | ||
{"scaled_float", ES_TYPE_FLOAT8}, | ||
{"keyword", ES_TYPE_VARCHAR}, | ||
{"text", ES_TYPE_VARCHAR}, | ||
{"date", ES_TYPE_TIMESTAMP}, | ||
{"object", ES_TYPE_VARCHAR}, | ||
{"nested", ES_TYPE_VARCHAR}, | ||
{"date", ES_TYPE_DATE}}; | ||
{ES_TYPE_NAME_BOOLEAN, ES_TYPE_BOOL}, | ||
{ES_TYPE_NAME_BYTE, ES_TYPE_INT2}, | ||
{ES_TYPE_NAME_SHORT, ES_TYPE_INT2}, | ||
{ES_TYPE_NAME_INTEGER, ES_TYPE_INT4}, | ||
{ES_TYPE_NAME_LONG, ES_TYPE_INT8}, | ||
{ES_TYPE_NAME_HALF_FLOAT, ES_TYPE_FLOAT4}, | ||
{ES_TYPE_NAME_FLOAT, ES_TYPE_FLOAT4}, | ||
{ES_TYPE_NAME_DOUBLE, ES_TYPE_FLOAT8}, | ||
{ES_TYPE_NAME_SCALED_FLOAT, ES_TYPE_FLOAT8}, | ||
{ES_TYPE_NAME_KEYWORD, ES_TYPE_VARCHAR}, | ||
{ES_TYPE_NAME_TEXT, ES_TYPE_VARCHAR}, | ||
{ES_TYPE_NAME_DATE, ES_TYPE_TIMESTAMP}, | ||
{ES_TYPE_NAME_OBJECT, ES_TYPE_VARCHAR}, | ||
{ES_TYPE_NAME_VARCHAR, ES_TYPE_VARCHAR}, | ||
{ES_TYPE_NAME_DATE, ES_TYPE_DATE}}; | ||
|
||
#define ES_VARCHAR_SIZE (-2) | ||
const std::unordered_map< OID, int16_t > oid_to_size_map = { | ||
|
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.
Can we use SQL type contstants here instead? (eg.
SQLWVARCHAR
)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.
added