This is an automated email from the ASF dual-hosted git repository.
jiadongb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new 356a240e2f fix(file-service): avoid manually constructing the Dataset
object through parameters (#3820)
356a240e2f is described below
commit 356a240e2fbb963187e4cd9e2bdfb673fb540d28
Author: Jiadong Bai <[email protected]>
AuthorDate: Thu Oct 9 16:57:13 2025 -0700
fix(file-service): avoid manually constructing the Dataset object through
parameters (#3820)
## Summary
- Fixed non-deterministic parameter ordering issue when creating Dataset
objects from JOOQ records
- Used `createdDataset.into(classOf[Dataset])` to convert DatasetRecord
to Dataset POJO instead of manual constructor
Fixes #3821
---------
Co-authored-by: Claude <[email protected]>
---
.../texera/service/resource/DatasetResource.scala | 11 +---------
.../service/resource/DatasetResourceSpec.scala | 25 +++++++++++++++++++++-
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git
a/core/file-service/src/main/scala/edu/uci/ics/texera/service/resource/DatasetResource.scala
b/core/file-service/src/main/scala/edu/uci/ics/texera/service/resource/DatasetResource.scala
index 97f2209bec..914e71ce5f 100644
---
a/core/file-service/src/main/scala/edu/uci/ics/texera/service/resource/DatasetResource.scala
+++
b/core/file-service/src/main/scala/edu/uci/ics/texera/service/resource/DatasetResource.scala
@@ -306,16 +306,7 @@ class DatasetResource {
datasetUserAccessDao.insert(datasetUserAccess)
DashboardDataset(
- new Dataset(
- createdDataset.getDid,
- createdDataset.getOwnerUid,
- createdDataset.getName,
- createdDataset.getRepositoryName,
- createdDataset.getIsPublic,
- createdDataset.getIsDownloadable,
- createdDataset.getDescription,
- createdDataset.getCreationTime
- ),
+ createdDataset.into(classOf[Dataset]),
user.getEmail,
PrivilegeEnum.WRITE,
isOwner = true,
diff --git
a/core/file-service/src/test/scala/edu/uci/ics/texera/service/resource/DatasetResourceSpec.scala
b/core/file-service/src/test/scala/edu/uci/ics/texera/service/resource/DatasetResourceSpec.scala
index 1a41488ebf..6c56606468 100644
---
a/core/file-service/src/test/scala/edu/uci/ics/texera/service/resource/DatasetResourceSpec.scala
+++
b/core/file-service/src/test/scala/edu/uci/ics/texera/service/resource/DatasetResourceSpec.scala
@@ -22,7 +22,7 @@ package edu.uci.ics.texera.service.resource
import edu.uci.ics.amber.core.storage.util.LakeFSStorageClient
import edu.uci.ics.texera.auth.SessionUser
import edu.uci.ics.texera.dao.MockTexeraDB
-import edu.uci.ics.texera.dao.jooq.generated.enums.UserRoleEnum
+import edu.uci.ics.texera.dao.jooq.generated.enums.{PrivilegeEnum,
UserRoleEnum}
import edu.uci.ics.texera.dao.jooq.generated.tables.daos.{DatasetDao, UserDao}
import edu.uci.ics.texera.dao.jooq.generated.tables.pojos.{Dataset, User}
import edu.uci.ics.texera.service.MockLakeFS
@@ -132,6 +132,29 @@ class DatasetResourceSpec
createdDataset.dataset.getIsDownloadable shouldBe true
}
+ it should "return DashboardDataset with correct owner email, WRITE
privilege, and isOwner=true" in {
+ val createDatasetRequest = DatasetResource.CreateDatasetRequest(
+ datasetName = "dashboard-dataset-test",
+ datasetDescription = "test for DashboardDataset properties",
+ isDatasetPublic = true,
+ isDatasetDownloadable = false
+ )
+
+ val dashboardDataset = datasetResource.createDataset(createDatasetRequest,
sessionUser)
+
+ // Verify the DashboardDataset properties
+ dashboardDataset.ownerEmail shouldEqual testUser.getEmail
+ dashboardDataset.accessPrivilege shouldEqual PrivilegeEnum.WRITE
+ dashboardDataset.isOwner shouldBe true
+ dashboardDataset.size shouldEqual 0
+
+ // Verify the underlying dataset properties
+ dashboardDataset.dataset.getName shouldEqual "dashboard-dataset-test"
+ dashboardDataset.dataset.getDescription shouldEqual "test for
DashboardDataset properties"
+ dashboardDataset.dataset.getIsPublic shouldBe true
+ dashboardDataset.dataset.getIsDownloadable shouldBe false
+ }
+
it should "delete dataset successfully if user owns it" in {
// insert a dataset directly into DB
val dataset = new Dataset