nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: googleapis/google-cloud-go
Pull request #3935 (2021-04-14 17:45:38)

feat(bigquery): support job deletion
Supports job.delete call.  Leaving in draft as this isn't pending backend release.


Patch:
diff --git a/bigquery/job.go b/bigquery/job.go
index 1e08e899c5..2d259f910b 100644
--- a/bigquery/job.go
+++ b/bigquery/job.go
@@ -233,6 +233,23 @@ func (j *Job) Cancel(ctx context.Context) error {
 	})
 }
 
+// Delete deletes the job.
+func (j *Job) Delete(ctx context.Context) (err error) {
+	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Job.Delete")
+	defer func() { trace.EndSpan(ctx, err) }()
+
+	call := j.c.bqs.Jobs.Delete(j.projectID, j.jobID).Context(ctx)
+	if j.location != "" {
+		call = call.Location(j.location)
+	}
+	setClientHeader(call.Header())
+
+	return runWithRetry(ctx, func() (err error) {
+		err = call.Do()
+		return err
+	})
+}
+
 // Wait blocks until the job or the context is done. It returns the final status
 // of the job.
 // If an error occurs while retrieving the status, Wait returns that error. But


Test patch:
diff --git a/bigquery/integration_test.go b/bigquery/integration_test.go
index 4206a44bc6..f9b160911f 100644
--- a/bigquery/integration_test.go
+++ b/bigquery/integration_test.go
@@ -2582,6 +2582,29 @@ func TestIntegration_ListJobs(t *testing.T) {
 	}
 }
 
+func TestIntegration_DeleteJob(t *testing.T) {
+	if client == nil {
+		t.Skip("Integration tests skipped")
+	}
+	ctx := context.Background()
+
+	q := client.Query("SELECT 17 as foo")
+	q.Location = "us-east1"
+
+	job, err := q.Run(ctx)
+	if err != nil {
+		t.Fatalf("job Run failure: %v", err)
+	}
+	_, err = job.Wait(ctx)
+	if err != nil {
+		t.Fatalf("job completion failure: %v", err)
+	}
+
+	if err := job.Delete(ctx); err != nil {
+		t.Fatalf("job.Delete failed: %v", err)
+	}
+}
+
 const tokyo = "asia-northeast1"
 
 func TestIntegration_Location(t *testing.T) {
Repository: googleapis/google-cloud-go
Pull request #3950 (2021-04-15 18:44:12)

feat(bigquery): support mutable clustering configuration
internal issue 185493320


Patch:
diff --git a/bigquery/table.go b/bigquery/table.go
index bc969227c7..f3493aed7b 100644
--- a/bigquery/table.go
+++ b/bigquery/table.go
@@ -356,7 +356,7 @@ func (rpr *RangePartitioningRange) toBQ() *bq.RangePartitioningRange {
 	}
 }
 
-// Clustering governs the organization of data within a partitioned table.
+// Clustering governs the organization of data within a managed table.
 // For more information, see https://cloud.google.com/bigquery/docs/clustered-tables
 type Clustering struct {
 	Fields []string
@@ -681,6 +681,10 @@ func (tm *TableMetadataToUpdate) toBQ() (*bq.Table, error) {
 		t.EncryptionConfiguration = tm.EncryptionConfig.toBQ()
 	}
 
+	if tm.Clustering != nil {
+		t.Clustering = tm.Clustering.toBQ()
+	}
+
 	if !validExpiration(tm.ExpirationTime) {
 		return nil, invalidTimeError(tm.ExpirationTime)
 	}
@@ -750,6 +754,11 @@ type TableMetadataToUpdate struct {
 	// When updating a schema, you can add columns but not remove them.
 	Schema Schema
 
+	// The table's clustering configuration.
+	// For more information on how modifying clustering affects the table, see:
+	// https://cloud.google.com/bigquery/docs/creating-clustered-tables#modifying-cluster-spec
+	Clustering *Clustering
+
 	// The table's encryption configuration.
 	EncryptionConfig *EncryptionConfig
 


Test patch:
diff --git a/bigquery/table_test.go b/bigquery/table_test.go
index cc5ed3007b..1ce48fdfca 100644
--- a/bigquery/table_test.go
+++ b/bigquery/table_test.go
@@ -399,6 +399,12 @@ func TestTableMetadataToUpdateToBQ(t *testing.T) {
 				ForceSendFields:        []string{"RequirePartitionFilter"},
 			},
 		},
+		{
+			tm: TableMetadataToUpdate{Clustering: &Clustering{Fields: []string{"foo", "bar"}}},
+			want: &bq.Table{
+				Clustering: &bq.Clustering{Fields: []string{"foo", "bar"}},
+			},
+		},
 	} {
 		got, _ := test.tm.toBQ()
 		if !testutil.Equal(got, test.want) {
Repository: googleapis/google-cloud-go
Pull request #4485 (2021-07-22 18:23:28)

feat(bigquery): support multistatement transaction statistics in jobs


Patch:
diff --git a/bigquery/job.go b/bigquery/job.go
index 0499da7d12..657d338e4b 100644
--- a/bigquery/job.go
+++ b/bigquery/job.go
@@ -372,6 +372,9 @@ type JobStatistics struct {
 
 	// ReservationUsage attributes slot consumption to reservations.
 	ReservationUsage []*ReservationUsage
+
+	// TransactionInfo indicates the transaction ID associated with the job, if any.
+	TransactionInfo *TransactionInfo
 }
 
 // Statistics is one of ExtractStatistics, LoadStatistics or QueryStatistics.
@@ -880,6 +883,7 @@ func (j *Job) setStatistics(s *bq.JobStatistics, c *Client) {
 		ParentJobID:         s.ParentJobId,
 		ScriptStatistics:    bqToScriptStatistics(s.ScriptStatistics),
 		ReservationUsage:    bqToReservationUsage(s.ReservationUsage),
+		TransactionInfo:     bqToTransactionInfo(s.TransactionInfo),
 	}
 	switch {
 	case s.Extract != nil:
@@ -983,3 +987,18 @@ func timelineFromProto(timeline []*bq.QueryTimelineSample) []*QueryTimelineSampl
 	}
 	return res
 }
+
+// TransactionInfo contains information about a multi-statement transaction that may have associated with a job.
+type TransactionInfo struct {
+	// TransactionID is the system-generated identifier for the transaction.
+	TransactionID string
+}
+
+func bqToTransactionInfo(in *bq.TransactionInfo) *TransactionInfo {
+	if in == nil {
+		return nil
+	}
+	return &TransactionInfo{
+		TransactionID: in.TransactionId,
+	}
+}


Test patch:
diff --git a/bigquery/integration_test.go b/bigquery/integration_test.go
index 25ba131c1f..09f72d6be8 100644
--- a/bigquery/integration_test.go
+++ b/bigquery/integration_test.go
@@ -2435,6 +2435,7 @@ func TestIntegration_Scripting(t *testing.T) {
 	sql := `
 	-- Declare a variable to hold names as an array.
 	DECLARE top_names ARRAY<STRING>;
+	BEGIN TRANSACTION;
 	-- Build an array of the top 100 names from the year 2017.
 	SET top_names = (
 	  SELECT ARRAY_AGG(name ORDER BY number DESC LIMIT 100)
@@ -2449,6 +2450,7 @@ func TestIntegration_Scripting(t *testing.T) {
 	  SELECT word
 	  FROM ` + "`bigquery-public-data`" + `.samples.shakespeare
 	);
+	COMMIT TRANSACTION;
 	`
 	q := client.Query(sql)
 	job, err := q.Run(ctx)
@@ -2506,6 +2508,12 @@ func TestIntegration_Scripting(t *testing.T) {
 		if cStatus.Statistics.ScriptStatistics.EvaluationKind == "" {
 			t.Errorf("child job %q didn't indicate evaluation kind", cj.ID())
 		}
+		if cStatus.Statistics.TransactionInfo == nil {
+			t.Errorf("child job %q didn't have transaction info present", cj.ID())
+		}
+		if cStatus.Statistics.TransactionInfo.TransactionID == "" {
+			t.Errorf("child job %q didn't have transactionID present", cj.ID())
+		}
 	}
 
 }
Repository: evant/kotlin-inject
Pull request #54 (2020-09-16 21:32:19)

Fix nested class references


Patch:
diff --git a/kotlin-inject-compiler-kapt/src/main/kotlin/me/tatarka/inject/compiler/kapt/Util.kt b/kotlin-inject-compiler-kapt/src/main/kotlin/me/tatarka/inject/compiler/kapt/Util.kt
index 1e35499..8ea5616 100644
--- a/kotlin-inject-compiler-kapt/src/main/kotlin/me/tatarka/inject/compiler/kapt/Util.kt
+++ b/kotlin-inject-compiler-kapt/src/main/kotlin/me/tatarka/inject/compiler/kapt/Util.kt
@@ -151,7 +151,7 @@ fun kotlinx.metadata.ClassName.asClassName(): ClassName {
     return if (split == -1) {
         ClassName("", this)
     } else {
-        ClassName(substring(0, split).replace('/', '.'), substring(split + 1))
+        ClassName(substring(0, split).replace('/', '.'), substring(split + 1).split('.'))
     }
 }
 


Test patch:
diff --git a/integration-tests/src/test/kotlin/me/tatarka/inject/test/ProvidesTest.kt b/integration-tests/src/test/kotlin/me/tatarka/inject/test/ProvidesTest.kt
index 733b40c..f15b5f3 100644
--- a/integration-tests/src/test/kotlin/me/tatarka/inject/test/ProvidesTest.kt
+++ b/integration-tests/src/test/kotlin/me/tatarka/inject/test/ProvidesTest.kt
@@ -5,6 +5,7 @@ import assertk.assertions.*
 import me.tatarka.inject.annotations.Component
 import me.tatarka.inject.annotations.Inject
 import me.tatarka.inject.annotations.Provides
+import me.tatarka.inject.test.different.DifferentPackageFoo
 import kotlin.test.Test
 
 class ProvidesFoo(val bar: ProvidesBar? = null)
@@ -168,6 +169,10 @@ class StringArrayFoo(val stringArray: Array<String>)
     abstract val basicType: ValConstructorBasicTypes
 }
 
+@Component abstract class ProvidesInnerClassComponent {
+    abstract val fooFactory: DifferentPackageFoo.Factory
+}
+
 class ProvidesTest {
 
     @Test fun generates_a_component_that_provides_a_dep_from_a_function() {
@@ -250,5 +255,11 @@ class ProvidesTest {
         assertThat(component.basicType.boolean).isTrue()
         assertThat(component.basicType.string).isEqualTo("a")
     }
+
+    @Test fun generates_a_component_that_references_an_inner_class() {
+        val component = ProvidesInnerClassComponent::class.create()
+
+        assertThat(component.fooFactory).isNotNull()
+    }
 }
 
diff --git a/integration-tests/src/test/kotlin/me/tatarka/inject/test/different/DifferentPackage.kt b/integration-tests/src/test/kotlin/me/tatarka/inject/test/different/DifferentPackage.kt
index 4f6caf6..4aedfd8 100644
--- a/integration-tests/src/test/kotlin/me/tatarka/inject/test/different/DifferentPackage.kt
+++ b/integration-tests/src/test/kotlin/me/tatarka/inject/test/different/DifferentPackage.kt
@@ -1,11 +1,14 @@
 package me.tatarka.inject.test.different
 
 import me.tatarka.inject.annotations.Component
+import me.tatarka.inject.annotations.Inject
 import me.tatarka.inject.annotations.Provides
 import me.tatarka.inject.test.CustomScope
 
-class DifferentPackageFoo
+class DifferentPackageFoo {
+    @Inject class Factory
+}
 
 @CustomScope @Component abstract class DifferentPackageScopedComponent {
     @Provides @CustomScope fun differentPackageFoo() = DifferentPackageFoo()
-}
\ No newline at end of file
+}
Repository: evant/kotlin-inject
Pull request #91 (2020-12-05 22:43:44)

Update ksp


Patch:
diff --git a/build.gradle b/build.gradle
index 762e3fb..f34a6d9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
 plugins {
-    id 'org.jetbrains.kotlin.jvm' version '1.4.10' apply false
+    id 'org.jetbrains.kotlin.jvm' version "$kotlin_version" apply false
     id 'symbol-processing' version "$ksp_version" apply false
     id "io.gitlab.arturbosch.detekt" version "1.14.2"
 }
diff --git a/gradle.properties b/gradle.properties
index decdede..b262f59 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,3 @@
-ksp_version=1.4.10-dev-experimental-20201023
-org.gradle.parallel=true
+kotlin_version=1.4.20
+ksp_version=1.4.20-dev-experimental-20201204
+org.gradle.parallel=true
\ No newline at end of file
diff --git a/kotlin-inject-compiler-ksp/build.gradle b/kotlin-inject-compiler-ksp/build.gradle
index 4f9df72..174c098 100644
--- a/kotlin-inject-compiler-ksp/build.gradle
+++ b/kotlin-inject-compiler-ksp/build.gradle
@@ -7,7 +7,7 @@ dependencies {
     implementation project(':kotlin-inject-compiler-core')
     implementation "org.jetbrains.kotlin:kotlin-stdlib"
     // for access to CompilationErrorException until ksp properly fails on errors
-    implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.0'
+    implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
     implementation "com.google.devtools.ksp:symbol-processing-api:$ksp_version"
 }
 


Test patch:
diff --git a/compiler-tests/build.gradle b/compiler-tests/build.gradle
index f5120c8..b68316b 100644
--- a/compiler-tests/build.gradle
+++ b/compiler-tests/build.gradle
@@ -10,7 +10,8 @@ dependencies {
     implementation project(':kotlin-inject-compiler-ksp')
 
     implementation 'com.github.tschuchortdev:kotlin-compile-testing-ksp:1.3.1'
-    implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.0'
+    implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
+    implementation "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:$kotlin_version"
     implementation "com.google.devtools.ksp:symbol-processing:$ksp_version"
     implementation "com.google.devtools.ksp:symbol-processing-api:$ksp_version"
Repository: evant/kotlin-inject
Pull request #99 (2021-04-05 17:06:07)

Fix scope key when using qualifiers


Patch:
diff --git a/kotlin-inject-compiler-core/src/main/kotlin/me/tatarka/inject/compiler/InjectGenerator.kt b/kotlin-inject-compiler-core/src/main/kotlin/me/tatarka/inject/compiler/InjectGenerator.kt
index 7a9547f..08818a5 100644
--- a/kotlin-inject-compiler-core/src/main/kotlin/me/tatarka/inject/compiler/InjectGenerator.kt
+++ b/kotlin-inject-compiler-core/src/main/kotlin/me/tatarka/inject/compiler/InjectGenerator.kt
@@ -311,7 +311,7 @@ class InjectGenerator<Output, Provider>(
                     SCOPED_COMPONENT
                 )
             }
-            add("_scoped.get(%S)", key.type).beginControlFlow("{")
+            add("_scoped.get(%S)", key).beginControlFlow("{")
             add(provide(key, context.withoutScoped(key.type)))
             endControlFlow()
         }.build()
@@ -590,4 +590,4 @@ fun AstClass.scopeClass(messenger: Messenger, options: Options): AstClass? {
         }
     }
     return elementScopeClass
-}
+}
\ No newline at end of file


Test patch:
diff --git a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/JavaxAnnotationTest.kt b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/JavaxAnnotationTest.kt
index 950d7ff..748069a 100644
--- a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/JavaxAnnotationTest.kt
+++ b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/JavaxAnnotationTest.kt
@@ -38,6 +38,25 @@ abstract class NamedComponent {
         @Provides @Named("two") get() = "two"
 }
 
+@Component
+@JavaxScope
+abstract class ScopedNamedComponent {
+
+    @get:Named("one")
+    abstract val one: String
+
+    @get:Named("two")
+    abstract val two: String
+
+    @get:JavaxScope
+    val provide1: String
+        @Provides @Named("one") get() = "one"
+
+    @get:JavaxScope
+    val provide2: String
+        @Provides @Named("two") get() = "two"
+}
+
 class JavaxAnnotationTest {
 
     @Test
@@ -54,4 +73,12 @@ class JavaxAnnotationTest {
         assertThat(component.one).isEqualTo("one")
         assertThat(component.two).isEqualTo("two")
     }
+
+    @Test
+    fun generates_a_scoped_component_that_supports_the_named_qualifier() {
+        val component = ScopedNamedComponent::class.create()
+
+        assertThat(component.one).isEqualTo("one")
+        assertThat(component.two).isEqualTo("two")
+    }
 }
\ No newline at end of file
Repository: evant/kotlin-inject
Pull request #121 (2021-04-21 18:11:46)

Fix type alias generics handling in ksp


Patch:
diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
index 29acfc2..747fadd 100644
--- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
+++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
@@ -402,7 +402,7 @@ private class KSAstType(provider: KSAstProvider, val type: KSType) : AstType(),
     override fun resolvedType(): AstType {
         val declaration = declaration
         return if (declaration is KSTypeAlias) {
-            KSAstType(this, declaration.type.resolve())
+            KSAstType(this, declaration.type.resolve().replace(type.arguments))
         } else {
             this
         }


Test patch:
diff --git a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
index 935597a..b337d77 100644
--- a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
+++ b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
@@ -69,6 +69,16 @@ abstract class TypeAliasMapComponent {
         @Provides @IntoMap get() = "2" to FooValue("2")
 }
 
+typealias Factory<T> = () -> T
+
+@Component
+abstract class TypeAliasIntoMapDependencyComponent {
+    abstract val items: Map<String, () -> Any?>
+
+    @Provides @IntoMap
+    fun foo(f: Factory<Foo>): Pair<String, () -> Any?> = "test" to f
+}
+
 class MultibindsTest {
 
     @Test
Repository: evant/kotlin-inject
Pull request #134 (2021-06-09 00:08:25)

Fixed not using the typealias for function return types
This can lose annotations which may be important (ex: @Composeable)


Patch:
diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
index e7491a9..02d772c 100644
--- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
+++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
@@ -68,7 +68,7 @@ val KSDeclaration.shortName: String
 fun KSType.asTypeName(): TypeName {
     val isFunction = isFunctionType
     val isSuspending = isSuspendFunctionType
-    if (isFunction || isSuspending) {
+    if ((isFunction || isSuspending) && declaration !is KSTypeAlias) {
         val returnType = arguments.last()
         val parameters = arguments.dropLast(1)
         return LambdaTypeName.get(


Test patch:
diff --git a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/InjectFunctionTest.kt b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/InjectFunctionTest.kt
index 24ea309..44feec8 100644
--- a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/InjectFunctionTest.kt
+++ b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/InjectFunctionTest.kt
@@ -1,11 +1,14 @@
 package me.tatarka.inject.test
 
 import assertk.assertThat
+import assertk.assertions.containsExactly
+import assertk.assertions.extracting
 import assertk.assertions.isEqualTo
 import me.tatarka.inject.annotations.Component
 import me.tatarka.inject.annotations.Inject
 import me.tatarka.inject.test.module.externalFunction
 import org.junit.Test
+import kotlin.reflect.full.declaredMembers
 
 @Component
 abstract class FunctionInjectionComponent {
@@ -26,6 +29,24 @@ typealias bar = () -> String
 @Inject
 fun bar(foo: foo): String = foo("test")
 
+@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.RUNTIME)
+annotation class FunctionAnnotation
+
+typealias baz = @FunctionAnnotation () -> String
+
+@Inject
+@FunctionAnnotation
+@Suppress("FunctionOnlyReturningConstant")
+fun baz(): String {
+    return "test"
+}
+
+@Component
+abstract class FunctionAnnotationInjectComponent {
+    abstract val baz: baz
+}
+
 class InjectFunctionTest {
 
     @Test
@@ -35,4 +56,14 @@ class InjectFunctionTest {
         assertThat(component.bar()).isEqualTo("test")
         assertThat(component.externalFunction()).isEqualTo("external")
     }
+
+    @Test
+    fun generates_a_component_that_provides_a_function_with_an_annotation() {
+        val component = FunctionAnnotationInjectComponent::class.create()
+        val member = component::class.declaredMembers.first { it.name == "baz" }
+        val annotations = member.returnType.annotations
+
+        assertThat(annotations).extracting { it.annotationClass }
+            .containsExactly(FunctionAnnotation::class)
+    }
 }
\ No newline at end of file