-
Notifications
You must be signed in to change notification settings - Fork 290
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
Enhance integration test suite #676
Conversation
6b7129f
to
fb9f4a7
Compare
cfd2427
to
3fee8d9
Compare
5ab2639
to
6b58cdc
Compare
056dc10
to
fef127f
Compare
athena-dynamodb/src/test/java/com/amazonaws/athena/connectors/dynamodb/DynamoDbIntegTest.java
Show resolved
Hide resolved
...rc/test/java/com/amazonaws/athena/connectors/elasticsearch/integ/ElasticsearchIntegTest.java
Outdated
Show resolved
Hide resolved
...rc/test/java/com/amazonaws/athena/connectors/elasticsearch/integ/ElasticsearchIntegTest.java
Show resolved
Hide resolved
// Remove the column-header row | ||
rows.remove(0); | ||
} | ||
List<Double> values = new ArrayList<>(); |
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.
Similar comment here as earlier about using .map() instead of .forEach() for these kinds of situations.
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.
not sure i understand the difference. rows
in practice has just one value. turning it into a stream just to run map
seems more roundabout.
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.
I don't feel strongly as to whether or not you should change this, which is why I approved the pull request in addition to leaving the comments before.
But if you're wondering about the reasoning:
Its a declarative vs imperative style (where declarative is preferred when possible).
More formally this (creating the list and then looping through it to add to it) is an antipattern called ITM (initialize then modify): https://www.youtube.com/watch?v=VV9vwFsaQ6U
In scala a .map()
is always used for situations like this instead (just transforming one collection into another) vs a .foreach()
which is meant for side effecting operations: https://stackoverflow.com/a/44042773
The youtube link above is mostly about c++ (although he has examples in python as well) and stackoverflow link is on scala, so its not a concept that is isolated to any single language.
It only seems roundabout because its not something that most Java developers are used to (unless they started with Java 8 and beyond), but this is also why they added all of this stuff to Java.
EDIT:
Also my original comment was about .map()
vs .foreach()
in general, I did not take into consideration that there was only a single element in the List, because a .foreach()
was being used in the diff.
For the situations where one knows that the resulting List only comprises of a single or few elements, then one can just use List.of(<element>)
instead of using a .foreach()
or .map()
athena-hbase/src/test/java/com/amazonaws/athena/connectors/hbase/integ/HbaseIntegTest.java
Show resolved
Hide resolved
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.
Looks good to me other than the small comments on:
map()
insteadforEach()
Map.of()
instead of Guava builderList.of()
instead of the Guava'sImmutableList.of()
athena-dynamodb/src/test/java/com/amazonaws/athena/connectors/dynamodb/DynamoDbIntegTest.java
Show resolved
Hide resolved
Add datatype conversion integ suite and implementation for PostgreSQL.
add some more testing
Ddb connector with extractor and GeneratedRowWriter (#704) Fix for Sql Server partition issue (#707) Corrected athena-snowflake.yaml description adding option for VPC config on elasticsearch connector Bigquery metadata pagination implementation && fixed bigquery table casesensitive issue BigQuery IAM role & policies changes in template file Fix a small typo in README.md Fix log4j logger configurations Enhance integration test suite (#676)
Ddb connector with extractor and GeneratedRowWriter (#704) Fix for Sql Server partition issue (#707) Corrected athena-snowflake.yaml description adding option for VPC config on elasticsearch connector Bigquery metadata pagination implementation && fixed bigquery table casesensitive issue BigQuery IAM role & policies changes in template file Fix a small typo in README.md Fix log4j logger configurations Enhance integration test suite (#676)
Add datatype conversion integration test suite and implementation for PostgreSQL.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.