Fix #275 - JSON Schemas have ambiguous types

This commit is contained in:
sureshms 2021-08-23 05:32:41 -07:00
parent cf0dcf8142
commit c0156ed270
8 changed files with 24 additions and 28 deletions

View File

@ -27,22 +27,14 @@ import org.slf4j.LoggerFactory;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class AuditEventHandler implements EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(AuditEventHandler.class);
private AuditLogRepository auditLogRepository;
private final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); // Quoted "Z" to indicate UTC,
// no timezone offset
public void init(CatalogApplicationConfig config, DBI jdbi) {
this.auditLogRepository = jdbi.onDemand(AuditLogRepository.class);
TimeZone tz = TimeZone.getTimeZone("UTC");
this.df.setTimeZone(tz);
}
public Void process(ContainerRequestContext requestContext,
@ -52,7 +44,7 @@ public class AuditEventHandler implements EventHandler {
if (responseContext.getEntity() != null) {
String path = requestContext.getUriInfo().getPath();
String username = requestContext.getSecurityContext().getUserPrincipal().getName();
String nowAsISO = df.format(new Date());
Date nowAsISO = new Date();
try {
EntityReference entityReference = EntityUtil.getEntityReference(responseContext.getEntity(),
@ -79,5 +71,4 @@ public class AuditEventHandler implements EventHandler {
}
public void close() {}
}

View File

@ -46,7 +46,8 @@
"type" : "integer"
},
"minimumInSyncReplicas" : {
"description": "Minimum number replicas in sync to control durability. For Kafka - `min.insync.replicas` configuration."
"description": "Minimum number replicas in sync to control durability. For Kafka - `min.insync.replicas` configuration.",
"type" : "integer"
},
"retentionSize": {
"description": "Maximum size of a partition in bytes before old data is discarded. For Kafka - `retention.bytes` configuration.",

View File

@ -234,8 +234,16 @@
"description": "Data for multiple rows of the table.",
"type": "array",
"items": {
"description": "Data for a single row of the table within the same order as columns fields.",
"type": "array"
"description": "Data for a single row of the table in the same order as `columns` fields.",
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "number"
}
]
}
}
},

View File

@ -96,7 +96,8 @@
"type" : "integer"
},
"minimumInSyncReplicas" : {
"description": "Minimum number replicas in sync to control durability. For Kafka - `min.insync.replicas` configuration."
"description": "Minimum number replicas in sync to control durability. For Kafka - `min.insync.replicas` configuration.",
"type" : "integer"
},
"retentionSize": {
"description": "Maximum size of a partition in bytes before old data is discarded. For Kafka - `retention.bytes` configuration.",

View File

@ -39,7 +39,7 @@
},
"threadTs": {
"description": "Timestamp of the when the first post created the thread.",
"format": "date-time"
"$ref": "../../type/basic.json#/definitions/dateTime"
},
"about": {
"description": "Data asset about which this thread is created for with format <#E/{enties}/{entityName}/{field}/{fieldValue}.",

View File

@ -58,7 +58,7 @@
"dateTime": {
"description": "Date and time in ISO 8601 format. Example - '2018-11-13T20:20:39+00:00'.",
"type": "string",
"format": "date-Time"
"format": "date-time"
},
"sqlQuery": {
"description": "SQL query statement. Example - 'select * from orders'.",

View File

@ -139,7 +139,7 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
@Test
public void post_validIngestionSchedules_as_admin_200(TestInfo test) throws HttpResponseException {
Schedule schedule = new Schedule().withStartDate(RestUtil.DATE_TIME_FORMAT.format(new Date()));
Schedule schedule = new Schedule().withStartDate(new Date());
schedule.withRepeatFrequency("PT60M"); // Repeat every 60M should be valid
createAndCheckService(create(test, 1).withIngestionSchedule(schedule), adminAuthHeaders());
@ -182,13 +182,12 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
DatabaseService dbService = createAndCheckService(create(test).withDescription(null).withIngestionSchedule(null),
adminAuthHeaders());
String id = dbService.getId().toString();
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
// Update database description and ingestion service that are null
UpdateDatabaseService update = new UpdateDatabaseService().withDescription("description1");
updateAndCheckService(id, update, OK, adminAuthHeaders());
// Update ingestion schedule
Schedule schedule = new Schedule().withStartDate(startDate).withRepeatFrequency("P1D");
Schedule schedule = new Schedule().withStartDate(new Date()).withRepeatFrequency("P1D");
update.withIngestionSchedule(schedule);
updateAndCheckService(id, update, OK, adminAuthHeaders());
@ -336,10 +335,9 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
}
public static CreateDatabaseService create(TestInfo test) {
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
return new CreateDatabaseService().withName(getName(test)).withServiceType(DatabaseServiceType.Snowflake)
.withJdbc(TestUtils.JDBC_INFO)
.withIngestionSchedule(new Schedule().withStartDate(startDate).withRepeatFrequency("P1D"));
.withIngestionSchedule(new Schedule().withStartDate(new Date()).withRepeatFrequency("P1D"));
}
private static CreateDatabaseService create(TestInfo test, int index) {

View File

@ -144,7 +144,7 @@ public class MessagingServiceResourceTest extends CatalogApplicationTest {
@Test
public void post_validIngestionSchedules_as_admin_200(TestInfo test) throws HttpResponseException {
Schedule schedule = new Schedule().withStartDate(RestUtil.DATE_TIME_FORMAT.format(new Date()));
Schedule schedule = new Schedule().withStartDate(new Date());
schedule.withRepeatFrequency("PT60M"); // Repeat every 60M should be valid
createAndCheckService(create(test, 1).withIngestionSchedule(schedule), adminAuthHeaders());
@ -187,13 +187,12 @@ public class MessagingServiceResourceTest extends CatalogApplicationTest {
MessagingService dbService = createAndCheckService(create(test).withDescription(null).withIngestionSchedule(null),
adminAuthHeaders());
String id = dbService.getId().toString();
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
// Update messaging description and ingestion service that are null
UpdateMessagingService update = new UpdateMessagingService().withDescription("description1");
updateAndCheckService(id, update, OK, adminAuthHeaders());
// Update ingestion schedule
Schedule schedule = new Schedule().withStartDate(startDate).withRepeatFrequency("P1D");
Schedule schedule = new Schedule().withStartDate(new Date()).withRepeatFrequency("P1D");
update.withIngestionSchedule(schedule);
updateAndCheckService(id, update, OK, adminAuthHeaders());
@ -336,17 +335,15 @@ public class MessagingServiceResourceTest extends CatalogApplicationTest {
}
public static CreateMessagingService create(TestInfo test) {
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
return new CreateMessagingService().withName(getName(test)).withServiceType(MessagingServiceType.Kafka)
.withBrokers(List.of("192.1.1.1:0"))
.withIngestionSchedule(new Schedule().withStartDate(startDate).withRepeatFrequency("P1D"));
.withIngestionSchedule(new Schedule().withStartDate(new Date()).withRepeatFrequency("P1D"));
}
private static CreateMessagingService create(TestInfo test, int index) {
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
return new CreateMessagingService().withName(getName(test, index)).withServiceType(MessagingServiceType.Pulsar)
.withBrokers(List.of("192.1.1.1:0"))
.withIngestionSchedule(new Schedule().withStartDate(startDate).withRepeatFrequency("P1D"));
.withIngestionSchedule(new Schedule().withStartDate(new Date()).withRepeatFrequency("P1D"));
}
public static void updateAndCheckService(String id, UpdateMessagingService update, Status status,