Skip to content
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

feat(bigquery): make rowIterator._to_dataframe_iterable public #10017

Merged

Conversation

HemangChothani
Copy link
Contributor

Fixes #7339

@HemangChothani HemangChothani requested review from tswast and a team December 26, 2019 05:52
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 26, 2019
row_iterator = self._make_one(
_mock_client(), api_request, path, schema, page_size=1, max_results=5
)
df = row_iterator.to_dataframe_iterable()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a generator, use a plural for the variable name dfs or dataframes.


self.assertIsInstance(df, types.GeneratorType)

a = next(df)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a is a Pandas DataFrame, so df or dataframe would be a more appropriate name.

{"f": [{"v": "Bhettye Rhubble"}, {"v": "27"}]},
]
path = "/foo"
api_request = mock.Mock(return_value={"rows": rows})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see side_effect used to test with multiple pages.

api_request = mock.Mock(return_value={"rows": rows})
row_iterator = self._make_one(_mock_client(), api_request, path, schema)

with self.assertRaises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use pytest.raises and match="pandas" to make sure that the ValueError occurs because of the missing pandas dependency.

@plamut plamut added the api: bigquery Issues related to the BigQuery API. label Dec 26, 2019
tswast
tswast previously approved these changes Dec 27, 2019
self.assertEqual(df_1.age.dtype.name, "int64")
self.assertEqual(len(df_1), 1) # verify the number of rows
self.assertEqual(
df_1.name._get_value(0), "Bengt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use _get_value(0) instead of df_1["name"][0]?

@tswast tswast dismissed their stale review December 27, 2019 15:32

Concerned about use of private _get_value in unit tests.

@HemangChothani
Copy link
Contributor Author

HemangChothani commented Jan 7, 2020

@tswast PTAL.

@tswast tswast self-requested a review January 7, 2020 17:12
@tswast tswast merged commit 240f381 into googleapis:master Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigQuery: Make RowIterator._to_dataframe_iterable public
4 participants